var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{
			string: navigator.userAgent,
			subString: "Chrome",
			identity: "Chrome"
		},
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari",
			versionSearch: "Version"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			   string: navigator.userAgent,
			   subString: "iPhone",
			   identity: "iPhone/iPod"
	    },
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();



var globalTtipObj=null;
var hasCheckBox_FirstColumn=false; // for kpi grid having checkbox, in jsp made it true if checkbox required
var allWindows= new Array();
var allWindows_adv= new Array();
var titleDivShowTimer;
var kpiMenuList= "";
var kpiGridWidthDivision= "";
var isAnalyst = false;
var layoutId_KPI = 0;
var layoutOrder_KPI = "";
var dimMesFil = false;

var topTopMenuBarList="";
var menuTopMenuBarList="";
var utilityTopMenuBarList="";
var utilityBottomMenuBarList="";
var utilityTopSingleMenuBarList="";
var isWorkFlowKPI="no";
//start:chitta
isNav = (document.all) ? false : true;
isIE = (document.all) ? true : false;
isIE6=navigator.userAgent.indexOf("MSIE 6.0")>0?true:false;

///start:floating menu
function makeFloat(popId){
if  (document.getElementById){(function(){
if (window.opera){document.write("<input type='hidden' id='Q' value=' '>");}
var n = 500;var dragok = false;var y,x,d,dy,dx;
function move(e){
if (!e) e = window.event;
 if (dragok){
  d.style.left = dx + e.clientX - x + "px";
  d.style.top  = dy + e.clientY - y + "px";
  return false;
 }
}
function down(e){if (!e) e = window.event;
var temp = (typeof e.target != "undefined")?e.target:e.srcElement;
if (temp.tagName != "HTML"|"BODY" && temp.id != popId){temp = (typeof temp.parentNode != "undefined")?temp.parentNode:temp.parentElement; }
if (temp.id == popId){if (window.opera){document.getElementById("Q").focus();}
 dragok = true; temp.style.zIndex = n++; d = temp; dx = parseInt(temp.style.left+0); dy = parseInt(temp.style.top+0); x = e.clientX; y = e.clientY;
 document.onmousemove = move; return false;}}
function up(){dragok = false;document.onmousemove = null;}document.onmousedown = down;document.onmouseup = up;
})();}}
///end:floating menu

function decimalValidation(object,e){var decExp=/^\d+(\.\d+)?$/;
var keyCode = getKeyCode(e);
if(!decExp.test(String.fromCharCode(keyCode)) && keyCode!=46 && keyCode!=8){return false;
}else{if(keyCode==46 && object.value.indexOf('.')>=0){return false;}return true;}}
function plan_showPopup(val,obj){

	 var obj_curLeftPos = 0;
	 var obj_curTopPos = 0;
	 if (obj.offsetParent){
		 while (obj.offsetParent) {
			 obj_curTopPos += obj.offsetTop;
			 obj_curLeftPos += obj.offsetLeft;
			 obj = obj.offsetParent;
		 }
	 } else if (obj.x){
		 obj_curTopPos += obj.y;
		 obj_curLeftPos += obj.x;
		}
	if(obj_curTopPos>500 && obj_curTopPos<730){obj_curTopPos=600}
	$("controlPop").style.left=obj_curLeftPos+30+"px";
	$("controlPop").style.top=obj_curTopPos+"px";
	$("controlPop").style.display="block";
	document.PlanningBudgeting.reset();
	switch (val) {
	   case "P":showHidePopupToggle('popPcntCnge','popGrth','popEqSprd','popClear','popStrtLine','popPropEqual','popRelPropAdjustment','popCopyPaste');break;
	   case "E":showHidePopupToggle('popEqSprd','popPcntCnge','popGrth','popClear','popStrtLine','popPropEqual','popRelPropAdjustment','popCopyPaste');break;
	   case "S":showHidePopupToggle('popStrtLine','popPcntCnge','popGrth','popEqSprd','popClear','popPropEqual','popRelPropAdjustment','popCopyPaste');break;
	   case "PE":showHidePopupToggle('popPropEqual','popPcntCnge','popGrth','popEqSprd','popClear','popStrtLine','popRelPropAdjustment','popCopyPaste');break;
	   case "RPA":showHidePopupToggle('popRelPropAdjustment','popClear','popPcntCnge','popGrth','popEqSprd','popStrtLine','popPropEqual','popCopyPaste');break;
	   case "C":showHidePopupToggle('popClear','popPcntCnge','popGrth','popEqSprd','popStrtLine','popPropEqual','popRelPropAdjustment','popCopyPaste');break;
	   case "CP":showHidePopupToggle('popCopyPaste','popGrth','popPcntCnge','popEqSprd','popClear','popStrtLine','popPropEqual','popRelPropAdjustment');break;
	}
	var popupCustomRadioOption=document.PlanningBudgeting.d1;
	for(r=0;r<popupCustomRadioOption.length;r++)
	{
		if(popupCustomRadioOption[r].value==val){popupCustomRadioOption[r].checked=true};
	}
	$(functionsBarPlanning).style.display="none";
}
//end:chitta

var modifiedValues = new Array();
var ctr=0;

var MONTH_NAMES=new Array('January','February','March','April','May','June','July','August','September','October','November','December','Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
var DAY_NAMES=new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sun','Mon','Tue','Wed','Thu','Fri','Sat');
function LZ(x) {return(x<0||x>9?"":"0")+x}

//Added by Malay for Write back (Planning and Budgeting)
var globalXmlDoc,globalUrl,planqtrSel,subSelVal;
function getNewDOMInstance(url)
{
try //Internet Explorer
  { xmlDoc=new ActiveXObject('Microsoft.XMLDOM'); }catch(e){
  try {xmlDoc=document.implementation.createDocument('','',null);} catch(e) {alert(e.message)}}//Firefox, Mozilla, Opera, etc.
	try { xmlDoc.async=false; xmlDoc.load(url);}catch(e) {alert(e.message)}
	return xmlDoc;
}

//Added by Malay for Write back (Planning and Budgeting)
function savePlanningViewT(maxVersionID,versionId,planId,viewId,option){
	if(option == "new"){
		savePlanningView(maxVersionID,planId,viewId,option);
	}else if(option == "update"){
		savePlanningView(versionId,planId,viewId,option)
	}
}

function storeColValue(){ctr=0;
var rows=mygrid.xmlLoader.doXPath("//rows/row",getNewDOMInstance(globalUrl));
	for(i=0;i<(mygrid.getRowsNum());i++)
	{
		for(j=0;j<mygrid.getColumnsNum();j++)
		{
			if(mygrid.cellType[j]=="ed")
			{
				var cellIdValue = rows[i].childNodes[parseInt(j)+1].attributes[0].value;
				if(cellIdValue.indexOf("_PB_") != -1){
					var cellVal = cellIdValue.split("_PB_");
					cellIdValue = cellVal[0] + "_PB_" + mygrid.cells(mygrid.getRowId(i),j).getValue().replace(/,/g,'');
				}
				stArVal(mygrid.getRowId(i),rows[i].childNodes[1].attributes[0].value,cellIdValue);

			}
		}
	}
	return modifiedValues;
}
//Added by Malay for context menu for (Planning and Budgeting)
//function stArVal(rowId,cellId,cellVal){modifiedValues[ctr]=rowId+"#"+cellId+"#"+cellVal;ctr++;}
function stArVal(rowId,firstCellIdValue,cellIdVal){modifiedValues[ctr]=rowId+"#"+firstCellIdValue+"#"+cellIdVal;ctr++;}
function showHidePopupToggle(showid,hideid1,hideid2,hideid3,hideid4,hideid5,hideid6,hideid7){
$(showid).style.display="block";
$(hideid1).style.display="none";
$(hideid2).style.display="none";
$(hideid3).style.display="none";
$(hideid4).style.display="none";
$(hideid5).style.display="none";
$(hideid6).style.display="none";
$(hideid7).style.display="none";
//for copy paste content
if(showid=='popCopyPaste'){
setGrowthValue('pcntCPSelMnth','pcntCPSelSale');
}
//below for percent change initialization
	$('pcntGrowth').style.display='none';$('pcntDirect').style.display='block';
	makeFloat("controlPop");
}
//End of context menu for (Planning and Budgeting)
function openWindow(val)
{
	closeWindow();
	var xVal=window.screen.width-20;
	var yVal=window.screen.height-145;
	allWindows[allWindows.length] = window.open(''+val+'','','top=50,left=5,height='+yVal+',width='+xVal+',status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes');
}

function closeWindow(){
	if(allWindows.length>0)
	{
		for(i=0;i<allWindows.length;i++){
		  if(allWindows[i] && !allWindows[i].closed){
			allWindows[i].close()
		  }
		}
	}
}

// Add seperate Advance bar oepning capalility
//Commented by Manoj as per sunil comments from Vikas on August 18 2010.

/*function openWindow_forAdvanceBar(val)
{
	closeWindow_forAdvanceBar();
	var xVal=window.screen.width-20;
	var yVal=window.screen.height-145;
	allWindows_adv[allWindows_adv.length] = window.open(''+val+'','','top=50,left=5,height='+yVal+',width='+xVal+',status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes');
}

function closeWindow_forAdvanceBar(){
	if(allWindows_adv.length>0)
	{
		for(i=0;i<allWindows_adv.length;i++){
		  if(allWindows_adv[i] && !allWindows_adv[i].closed){
			allWindows_adv[i].close()
		  }
		}
	}
}*/

/*Loading*/

if(BrowserDetect.browser=='Explorer'){
	window.onscroll=function(){updateloaderLoc(event);updatebox(event);}
}else{
	window.onscroll=function(event){updateloaderLoc(event);updatebox(event);}
}
//window.onerror = handleError;
function handleError (err, url, line) {
	//Not handling any errors.
    return true;
  }

function updateloaderLoc(evt)
{
	   mouseX=evt.pageX?evt.pageX:evt.clientX;
	   mouseY=evt.pageY?evt.pageY:evt.clientY;
	   mouseY = mouseY + document.documentElement.scrollTop;

	   /*if((mouseX<=75 || mouseX>=(window.screen.width-75)) || (mouseY<=75 || mouseY>=(window.screen.height-125)))
	   {
	       if(document.getElementById('winLoader'))document.getElementById('winLoader').style.left = window.screen.width/2 + "px";
	   	   if(document.getElementById('winLoader'))document.getElementById('winLoader').style.top = window.screen.height/2 + "px";
	       if(document.getElementById('winLoaderDrillDown'))document.getElementById('winLoaderDrillDown').style.left = window.screen.width/2 + "px";
	   	   if(document.getElementById('winLoaderDrillDown'))document.getElementById('winLoaderDrillDown').style.top = window.screen.height/2 + "px";
	   }
	   else
	   {*/
		   if(document.getElementById('winLoader'))document.getElementById('winLoader').style.left=mouseX + "px";
		   if(document.getElementById('winLoader'))document.getElementById('winLoader').style.top=mouseY + "px";
		   if(document.getElementById('winLoaderDrillDown'))document.getElementById('winLoaderDrillDown').style.left=mouseX + "px";
		   if(document.getElementById('winLoaderDrillDown'))document.getElementById('winLoaderDrillDown').style.top=mouseY + "px";
	  // }
 }

function updatebox(evt) {
	   mouseX=evt.pageX?evt.pageX:evt.clientX;
	   mouseY=evt.pageY?evt.pageY:evt.clientY;
	   mouseY = mouseY + document.documentElement.scrollTop;

	  /* if((mouseX<=75 || mouseX>=(window.screen.width-75)) || (mouseY<=75 || mouseY>=(window.screen.height-125)))
	   {
	       if(document.getElementById('winLoader'))document.getElementById('winLoader').style.left = window.screen.width/2 + "px";
	   	   if(document.getElementById('winLoader'))document.getElementById('winLoader').style.top = window.screen.height/2 + "px";
	       if(document.getElementById('winLoaderDrillDown'))document.getElementById('winLoaderDrillDown').style.left = window.screen.width/2 + "px";
	   	   if(document.getElementById('winLoaderDrillDown'))document.getElementById('winLoaderDrillDown').style.top = window.screen.height/2 + "px";
	   }
	   else
	   {*/
		   if(document.getElementById('winLoader'))document.getElementById('winLoader').style.left=mouseX + "px";
		   if(document.getElementById('winLoader'))document.getElementById('winLoader').style.top=mouseY + "px";
		   if(document.getElementById('winLoaderDrillDown'))document.getElementById('winLoaderDrillDown').style.left=mouseX + "px";
		   if(document.getElementById('winLoaderDrillDown'))document.getElementById('winLoaderDrillDown').style.top=mouseY + "px";
	  // }
 }

function showWorking() {
	if(document.getElementById('systemWorking')){
		document.getElementById('systemWorking').style.display='block';
	}
}
function hideWorking() {
	if(document.getElementById('systemWorking')){
		document.getElementById('systemWorking').style.display='none';
	}
}

function executeActiveTab()
{
	allChildsOfUtility = document.getElementById('menuTop').childNodes;

	for(i=0; i<allChildsOfUtility.length; i++)
	{
		if(allChildsOfUtility[i].className=="menuBarRightActive_M")
		{
			selectObj = document.getElementById(allChildsOfUtility[i].id).childNodes[0];
			selectObj.onclick();
		}
	}
}

function hideExtraUtilities(val, val1){
	Element.cleanWhitespace(document.getElementById(val));
	allChildsOfUtility = document.getElementById(val).childNodes;
	for(i=allChildsOfUtility.length-1; i>=0; i--){
		//FireFox Fix Not required for isNav checking
		//(isNav && document.getElementById(val).parentNode.offsetHeight>=34) ||
		if(val=='admenuTop'){
			var strNodesHeight = document.getElementById(val).parentNode.offsetHeight;
		}else{
			var strNodesHeight = document.getElementById(val).offsetHeight;
		}

		if(strNodesHeight>=34){
			if((val=='topTop' || val=='admenuTop') && i>1){
				allChildsOfUtility[i-1].style.display='none';
			}
			else if(val=='utilityTopSingle' || val=='utilityTop' ){
					allChildsOfUtility[i-2].style.display='none';
			}
			else{
				allChildsOfUtility[i].style.display='none';
			}
		}
	}
	if(document.getElementById(val1))
	document.getElementById(val1).style.display='';
	for(i=allChildsOfUtility.length-1; i>=0; i--){
		var heightM = document.getElementById(val).offsetHeight;
		if(val=='menuTop' || val =='topTop'){
			heightM = document.getElementById(val).parentNode.parentNode.offsetHeight;
		}
		if(heightM>=34)
		{
			if(allChildsOfUtility[i]!=allChildsOfUtility[allChildsOfUtility.length] && allChildsOfUtility[i]!=allChildsOfUtility[allChildsOfUtility.length-1])
			{
				allChildsOfUtility[i].style.display='none';
			}
		}
	}
}

/*Loading*/

/* TOP BAR */
var currTopToolClass='';
function onTopToolConfig(div)
{
	currTopToolClass = div.className;
	div.className='topBarConfigActive';
}
function offTopToolConfig(div)
{
	div.className=currTopToolClass;
}

var currMyBarClass=''
function onMyBar(div)
{
	currMyBarClass = div.className;
	div.className='topBarElementActive';
}
function offMyBar(div)
{
	div.className=currMyBarClass;
}

var currMyBarClass1=''
function onMyBar1(div)
{
	currMyBarClass1 = div.className;
	div.className='topBarElementActive1';
}
function offMyBar1(div)
{
	div.className=currMyBarClass1;
}
/* TOP BAR ENDS */


/*MENU BAR */
var currMenuToolClass='';

function onMenuToolConfig(div)
{
	currMenuToolClass = div.className;
	div.className='menuBarConfigActive';
}
function offMenuToolConfig(div)
{
	div.className=currMenuToolClass;
}

var currMenuBarClass=''
var currParentMenuBarClass=''
function onMenuBar(div)
{
	currMenuBarClass = div.className;
	currParentMenuBarClass = div.parentNode.className;
	div.className='menuBarLeftHigh';
	div.parentNode.className='menuBarRight_MHigh';
}
function offMenuBar(div)
{
	div.className=currMenuBarClass;
	div.parentNode.className=currParentMenuBarClass;
}

function changeMenuState(val){
	for(i=0; i<document.getElementById(val).parentNode.childNodes.length-1; i++){
		if(document.getElementById(val).parentNode.childNodes[i].innerHTML!=null){
			document.getElementById(val).parentNode.childNodes[i].className='menuBarRight_M';
				if (isNav){
				 if(document.getElementById(val).parentNode.childNodes[i].childNodes[0]!=null){
					document.getElementById(val).parentNode.childNodes[i].childNodes[0].className='menuBarLeft';
				}if(document.getElementById(val).parentNode.childNodes[i].childNodes[0].onmouseout==null){
					document.getElementById(val).parentNode.childNodes[i].childNodes[0].onmouseover = function() {onMenuBar(this)};
					document.getElementById(val).parentNode.childNodes[i].childNodes[0].onmouseout = function() {offMenuBar(this)};
				}
			}
			else if (isIE){
				document.getElementById(val).parentNode.childNodes[i].childNodes[0].className='menuBarLeft';
				if(document.getElementById(val).parentNode.childNodes[i].childNodes[0].onmouseout==null){
					document.getElementById(val).parentNode.childNodes[i].childNodes[0].onmouseover = function() {onMenuBar(this)};
					document.getElementById(val).parentNode.childNodes[i].childNodes[0].onmouseout = function() {offMenuBar(this)};
				}
			}
		}
	}
	document.getElementById(val).childNodes[0].className='menuBarLeftActive';
	document.getElementById(val).className='menuBarRightActive_M';
	document.getElementById(val).childNodes[0].onmouseout= null;
	document.getElementById(val).childNodes[0].onmouseover= null;
}


function showHiddenMenu(val, val1, val3)
{
	var checkboxArrayIDs = "";
	if(document.getElementById(val).style.display == 'none')
	{
		checkboxArray = val1.parentNode.parentNode.parentNode.getElementsByTagName("li");
		for(i=0; i<checkboxArray.length; i++)
		{
			//alert(checkboxArray[i].attributes["itemID"].value);
			checkboxArrayIDs = checkboxArrayIDs +","+ checkboxArray[i].attributes["itemID"].value;
		}

		checkboxArrayIDs = checkboxArrayIDs.split(",");

		if(val3 == 'admin'){
			allChildsOfUtility = document.getElementById('admenuTop').childNodes;
		}
		else{
			allChildsOfUtility = document.getElementById('menuTop').childNodes;
		}

		for(i=allChildsOfUtility.length-1; i>1; i--)
		{
			if(allChildsOfUtility[i-1].id == "9_module" || allChildsOfUtility[i-1].id == "menu_myDashboard"){
				strVal = 2;
			}
			else{
				if(val3 == 'admin')
					strVal = 2;
				else
					strVal = 1;
			}
			if(allChildsOfUtility[i-strVal].style.display!='none')
			{
				allChildsOfUtility[i-strVal].style.display='none';

				for(j=0; j<checkboxArrayIDs.length; j++)
				{

						if(allChildsOfUtility[i-strVal].id == checkboxArrayIDs[j])
						{
							callHideCheck(checkboxArrayIDs[j], val1, val3);
						}

				}

				break;
			}
		}
		val1.parentNode.childNodes[0].click();
	}

}
function callHideCheck(val, val1, val3)
{
		if(val3 != 'admin'){
			checkboxArray = val1.parentNode.parentNode.parentNode.getElementsByTagName("li");
		}else{
			checkboxArray = val1.parentNode.parentNode.getElementsByTagName("li");
		}
		for(i=0; i<checkboxArray.length; i++)
		{
			if(checkboxArray[i].attributes["itemID"].value == val)
			{
				if(val3 != 'admin'){
				checkboxArray[i].childNodes[0].childNodes[0].checked = false;
				}
				else{
				checkboxArray[i].childNodes[0].checked = false;
				}
			}
		}
}

/*MENU BAR ENDS*/

/*ADMIN MENU*/
	var currMenuBarAdminClass=''
	var currParentMenuBarAdminClass=''
	function onMenuBarAdmin(div)
	{
		currMenuBarAdminClass = div.className;
		currParentMenuBarAdminClass = div.parentNode.className;
		div.className='menuBarAdminLeftHigh';
		div.parentNode.className='menuBarAdminRight_MHigh';
	}
	function offMenuBarAdmin(div){
		div.className=currMenuBarAdminClass;
		div.parentNode.className=currParentMenuBarAdminClass;
	}

	function changeMenuAdminState(val){
		closeALLAdminSubMenu();
		eval("document.getElementById('"+val.parentNode.id+"CON').style.display='block'");
		for(i=0; i<val.parentNode.parentNode.childNodes.length-1; i++){
			if(val.parentNode.parentNode.childNodes[i].innerHTML!=null){
				val.parentNode.parentNode.childNodes[i].className='menuBarAdminRight_M';
				if (isNav && !isIE){
					if(val.parentNode.parentNode.childNodes[i].childNodes[1]!=null){
						val.parentNode.parentNode.childNodes[i].childNodes[1].className='menuBarAdminLeft';
					}
					if(val.parentNode.parentNode.childNodes[i].childNodes[1].onmouseout==null){
						val.parentNode.parentNode.childNodes[i].childNodes[1].onmouseover = function() {onMenuBarAdmin(this)};
						val.parentNode.parentNode.childNodes[i].childNodes[1].onmouseout = function() {offMenuBarAdmin(this)};
						val.parentNode.parentNode.childNodes[i].childNodes[1].onclick = function() {changeMenuAdminState(this)};
					}
				}
				else if (isIE && !isNav){
					val.parentNode.parentNode.childNodes[i].childNodes[0].className='menuBarAdminLeft';
					if(val.parentNode.parentNode.childNodes[i].childNodes[0].onmouseout==null)
					{
						val.parentNode.parentNode.childNodes[i].childNodes[0].onmouseover = function() {onMenuBarAdmin(this)};
						val.parentNode.parentNode.childNodes[i].childNodes[0].onmouseout = function() {offMenuBarAdmin(this)};
						val.parentNode.parentNode.childNodes[i].childNodes[0].onclick = function() {changeMenuAdminState(this)};
					}
				}
			}
		}
		val.className='menuBarAdminLeftActive';
		val.parentNode.className='menuBarAdminRightActive_M';
		val.onmouseout= null;
		val.onmouseover= null;
	}

	function closeALLAdminSubMenu()
	{
		obj = document.getElementById('adminSubMenu');
		for(i=0; i<=obj.childNodes.length-1; i++)
		{
			obj.childNodes[i].style.display='none';
		}
	}

	var currAdminClass='';
	var currAdminParentClass='';
	function onButtonAdmin(div)
	{
		currAdminClass = div.className;
		currAdminParentClass = div.parentNode.className;
		div.className='buttonAdminLeftActive';
		div.parentNode.className='buttonAdminRightActive_M';
	}
	function offButtonAdmin(div)
	{
		div.className=currAdminClass;
		div.parentNode.className=currAdminParentClass;
	}

/*ADMIN MENU ENDS*/

/* UTILITY BAR */
var currClass='';
var currParentClass='';
function onButton(div)
{
	currClass = div.className;
	currParentClass = div.parentNode.className;
	div.className='buttonLeftActive';
	div.parentNode.className='buttonRightActive_M';
}
function offButton(div)
{
	div.className=currClass;
	div.parentNode.className=currParentClass;
}


var currToolClass='';
function onToolConfig(div)
{
	currToolClass = div.className;

	div.className='toolConfigActive';
}
function offToolConfig(div)
{
	div.className=currToolClass;
}


function showHover(val, val1, evt)
{
	document.getElementById(val).style.display='block';
	document.getElementById(val).style.top = "-2000px";
	document.getElementById('hoverContent').innerHTML=val1;

	mouseX=evt.pageX?evt.pageX:evt.clientX;
	mouseY=evt.pageY?evt.pageY:evt.clientY;

	document.getElementById(val).style.left=mouseX + "px";
	topY=(mouseY+25) + document.documentElement.scrollTop;
	topX=(mouseX+25) + document.documentElement.scrollLeft;

	timerPopup = setTimeout("showHoverAtHeight('"+val+"', '"+topY+"', '"+topX+"'); clearTimeout(timerPopup)", "10");
}

function showHoverAtHeight(val, topY, topX)
{
	divHeight = document.getElementById(val).offsetHeight;
	divWidth = document.getElementById(val).offsetWidth;
	if((parseInt(topY)+parseInt(divHeight))>= parseInt(window.screen.height-170)){
		topY = topY - parseInt(divHeight + 10);
	}
	if(typeof(thisPageHeight)!="undefined"){
		if(parseInt(topY+divHeight) >= parseInt(thisPageHeight-20))	{
			topY = topY - parseInt(divHeight + 20);
		}
	}
	if(parseInt(topX) + parseInt(divWidth) >= (window.screen.width - 10)){
		topX = topX - parseInt(divWidth + 10);
	}
	if(topY < 0){topY = 0;}
	document.getElementById(val).style.left = topX + "px";
	document.getElementById(val).style.top = topY + "px";
}

function hideHover(val)
{
		document.getElementById(val).style.display='none';
}

/*var timer;
var effFlag;
var delayeffI=100;*/
var hideFlag=true;
function checkOnlyShownItems(val, val1)
{
	listID= document.getElementById(val);
	elementID= document.getElementById(val1);

	for(m=0; m<=elementID.childNodes.length -1; m++)
	{
		if(elementID.childNodes[m].style && elementID.childNodes[m].style.display=='none')
		{
			for(j=0; j<=listID.childNodes.length -1; j++)
			{
				itemInput = listID.childNodes[j].getAttribute('itemID');
				if(itemInput == elementID.childNodes[m].id)
				{
					if(itemInput != "uti_1_seperator" && itemInput != "")
					listID.childNodes[j].getElementsByTagName("input")[0].checked = false;
				}
			}
		}
	}
}
/*FireFox Fix:: outerHTML not working*/
function getOuterHTML(object) {
	if (BrowserDetect.browser=="Explorer"){
		return object.outerHTML;
	}
	else{
		var element = document.createElement('div');
		element.appendChild(object.cloneNode(true));
		return element.innerHTML;
	}
}

function showMoreUtilities(val, val1, val2, val3){
		if(userSelectedTheme == "green" || userSelectedTheme == "silver" || userSelectedTheme == "classic")
			var strRowHeight = "32";
		else
			var strRowHeight = "24";
		if(val=='kpiUtilities'){
			var strUtilitylength = 5;
		}
		else if(val=='kpiReportUtilities'){
			var strUtilitylength = 3;
		}
		else if(val=='kpiGraphUtilities'){
			var strUtilitylength = 2;
		}
		var extraWidth = 115;
		if(BrowserDetect.browser=='Firefox'){
			var cleanChildNodes = document.getElementById(val).cleanWhitespace();
			var allChildsOfUtility = cleanChildNodes.childNodes;
		}else{
		var allChildsOfUtility = document.getElementById(val).childNodes;
		}

		var strHiddenListIDs = "";
		var stringMsg ="";
		var ubarWidth=0;
		var showDrilFlg=false;
		var tmpLegacyHtml="";
		if(displayUtilityIconName < '2'){
			for(i=0;i<=(allChildsOfUtility.length - strUtilitylength);i++){
				//Condition Added for Avoiding Headers in Graph Section
				if(allChildsOfUtility[i].className != "")
				 {
		    		 allChildsOfUtility[i].style.width = "16px";
		    		 allChildsOfUtility[i].style.overflow = "hidden";
	    		 }
	    	}
		}
		for(i=0;i<=(allChildsOfUtility.length - strUtilitylength);i++)
		{
		  // if(allChildsOfUtility[i].style){
		   		allChildsOfUtility[i].style.display="";
		   //}

		   ubarWidth+=allChildsOfUtility[i].offsetWidth!=undefined?parseInt(allChildsOfUtility[i].offsetWidth,10):0;
		   if(ubarWidth>($(val).offsetWidth-extraWidth)){
			   if(allChildsOfUtility[i].className == "kpiUtilityBarSeperator"){
						stringMsg += "<div class='toolbarDivider'>&nbsp;</div>";
				}else{
						tmpLegacyHtml= getOuterHTML(allChildsOfUtility[i]);
					if(tmpLegacyHtml.indexOf("checkExport(")== -1){
				    	tmpLegacyHtml=tmpLegacyHtml.split("onKPIUtilityBar(this)")[0]+"checkExport();onKPIUtilityBar(this);"+tmpLegacyHtml.split("onKPIUtilityBar(this)")[1];
				    }
					if(tmpLegacyHtml.indexOf("showUtilityBar(")>0 && tmpLegacyHtml.indexOf("saveGraph")<0){//// need to check
							if(BrowserDetect.browser=='Firefox'){
								tmpLegacyHtml = tmpLegacyHtml.split("checkExport();onKPIUtilityBar(this);")[0]+"javascript:checkExport();onKPIUtilityBar(this);"+allChildsOfUtility[i].attributes["onclick"].value+""+tmpLegacyHtml.split("checkExport();onKPIUtilityBar(this);")[1];
							}else{
						tmpLegacyHtml = tmpLegacyHtml.split("checkExport();onKPIUtilityBar(this);")[0]+"\"javascript:checkExport();onKPIUtilityBar(this);"+allChildsOfUtility[i].attributes["onclick"].value+"\""+tmpLegacyHtml.split("checkExport();onKPIUtilityBar(this);")[1];
					}
						}

					if(allChildsOfUtility[i].className == "kpiUtilityBarDis" ){
					    	tmpLegacyHtml = getOuterHTML(allChildsOfUtility[i]);
				    }
					if(allChildsOfUtility[i].style.display != 'none'){
						if(displayUtilityIconName == '1'){
								if(BrowserDetect.browser=='Firefox'){
									var temp = tmpLegacyHtml.split("width: 16px");
								}else{
							var temp = tmpLegacyHtml.split("WIDTH: 16px");
								}
							tmpLegacyHtml = temp[0] + temp[1];
						}
						allChildsOfUtility[i].style.width = "";
						stringMsg += "<div style='position:relative;float:left;padding:1px 1px 1px 0px; width:98.5%'>" + tmpLegacyHtml + "</div><br/>\n" ;

					}
				}
				stringMsg += "<img src='images/spacer.gif' alt='' width='50' height='5'/><br />"  ;
			    allChildsOfUtility[i].style.display='none';
			    showDrilFlg=true;
		   }
		}
		if(showDrilFlg)
			$(val2).style.display='block';

		document.getElementById(val1).innerHTML = stringMsg.replace(/none/g,'block');
		document.getElementById(val1).style.paddingBottom="5px";

		if(document.getElementById(val1).innerHTML == ''){
			document.getElementById(val2).style.display = 'none';
		}
		// Deallocating the Memory
		allChildsOfUtility = null;
		strHiddenListIDs = null;
		stringMsg = null;
		ubarWidth=null;
		showDrilFlg=null;
		tmpLegacyHtml=null;
		strRowHeight = null;
		strUtilitylength = null;
}

var globalCloseId = "";

function showUtilityBar(val, val1)
{
	idSplit = val.split("##");
	if(idSplit[1])
	{
		globalCloseId = idSplit[0].substring(0,8);
	}
	else
	{
		globalCloseId = val;
	}

	if(val.indexOf('swapView') != -1 && val.indexOf('##') != -1){
		var splitVal = val.split('##');
		val = splitVal[0];
		buildSwapView(splitVal[1],splitVal[2]);
	}
	if(val=='utilityBarPopup1')
	{
		checkOnlyShownItems('utilityDinamicList', 'utilityTop')
	}

	if(val=='menuBarPopup1')
	{
		checkOnlyShownItems('utilityDinamicList1', 'menuTop')
	}
	if(val=='utilityBarPopup2')
	{
		checkOnlyShownItems('utilityDinamicList2', 'utilityTop')
	}
	if(val=='topUtilityBarPopup')
	{
		checkOnlyShownItems('utilityDinamicList3', 'topTop')
	}
	if(val=='utilityBarPopup3')
	{
		checkOnlyShownItems('utilityDinamicList4', 'utilityTopSingle')
	}
	if(val=='adutilityBarPopup')
	{
		checkOnlyShownItems('adutilityDinamicList', 'admenuTop')
	}
	if(val=='kpiUtilityBar2')
	{
		if(document.getElementById('menuUtilityBar2').innerHTML == ''){
			document.getElementById(val).style.display = 'none';
			return;
		}
	}

	if(val=='kpiUtilityBar3')
	{
		if(document.getElementById('menuUtilityBar3').innerHTML == ''){
			document.getElementById(val).style.display = 'none';
			return;
		}
	}
	if(val=='kpiUtilityBar4')
	{
		if(document.getElementById('menuUtilityBar4').innerHTML == ''){
			document.getElementById(val).style.display = 'none';
			return;
		}
	}
	if(val=='kpiUtilityBar5')
	{
		if(document.getElementById('menuUtilityBar5').innerHTML == ''){
			document.getElementById(val).style.display = 'none';
			return;
		}
	}
	document.getElementById(val).style.display='block';
	document.getElementById(val).style.position='absolute';
	document.getElementById(val).style.zIndex=99999;

	var obj_curLeftPos = 0;
	var obj_curTopPos = 0;
	obj=val1;
	if( BrowserDetect.browser=="Firefox" && ( val == "addBaseMeasure" || val == "addComputedMeasures" || val == "addDimensionAttribute"  ) ){
		$('kpiUtilityBar3').style.display='block';
	}
	if (obj.offsetParent){
		 while (obj.offsetParent) {
				if(document.getElementById('dataGridContainer') && document.getElementById('dataGridContainer').style.position=='absolute')
				{}
				else
				{
					obj_curTopPos += obj.offsetTop;
				}
			 obj_curLeftPos += obj.offsetLeft;
			 obj = obj.offsetParent;
		 }
	} else if (obj.x){
		 obj_curTopPos += obj.y;
		 obj_curLeftPos += obj.x;
	}
	if( BrowserDetect.browser=="Firefox" && ( val == "addBaseMeasure" || val == "addComputedMeasures" || val == "addDimensionAttribute"  ) ){
		$('kpiUtilityBar3').style.display='none';
	}
	if(val == "graphConfigSettings" || val=="filterSeq" || val=="viewSeq" || val=="totalCoulmns" || val=="visibleCoulmns" ||  val == "measureSeq" || val == "orderCoulmns"  || val == "drillDown" ){
		document.getElementById(val).style.left = (obj_curLeftPos - 140) + "px";
	}

	else if(val == "addBaseMeasure" || val == "addComputedMeasures" || val == "addDimensionAttribute" || val =="crosstabSort"){
		document.getElementById(val).style.left = (obj_curLeftPos - 240) + "px";
	}

	else if( val!='crosstabCols' && val!='crosstabTotal' && val!='showGroupMeasures' && val !='showNewColumnCal' && val!= 'changeMeasuresName' && val1.attributes["onmouseover"].value.indexOf(val)>0){
		if(val=="customizeLinkKpi"){$("customizeG").style.display='none';}
	    else{if($("customizeLinkKpi"))$("customizeLinkKpi").style.display='none';}
	    if(val == "exportOptions")
	     {
	   	 	document.getElementById(val).style.width = "130px";
	   	 	document.getElementById(val).style.left = (obj_curLeftPos - 132) + "px";
	   	 }
		else{
	   		document.getElementById(val).style.left = (obj_curLeftPos - 162) + "px";
	   	}
	     document.getElementById(val).style.top = (obj_curTopPos-20) +"px";
	     globalCloseId="";
	    return;
	}else{
		document.getElementById(val).style.left = obj_curLeftPos + "px";
	}
	if(typeof prodAfinityBaseProd=='undefined' || val=="kpiUtilityBar3")

	document.getElementById(val).style.top = obj_curTopPos+ "px";
	screenWidth = document.body.clientWidth + "px";

	divLeft = (val1.offsetLeft + document.getElementById(val).offsetWidth) + "px";
	divLeft = parseInt(divLeft);
	screenWidth =parseInt(screenWidth);

	if(divLeft >= screenWidth)
	{
		extraWidth = parseInt(divLeft) - parseInt(screenWidth);
		newWidth = parseInt(document.getElementById(val).style.left) - extraWidth;
		document.getElementById(val).style.left = newWidth - 8 + "px";
	}
		// for custom module pdf file rendering on iframe creates problem for that below code;
	if(val=='menuBarPopup1')
	{
		document.getElementById("menuHeaderPdfFix").style.height=document.getElementById("toolBarContainer").offsetHeight+"px";
		document.getElementById("toolBarContainer").childNodes[0].style.width="176px";
	}

	if(val=='drillDown' || val=='drillAccross' || val=='selectType' || val=='topNumNameDiv')
	{
		if (document.getElementById('viewDragTable')){
			document.getElementById(val).style.top = document.getElementById(val).offsetTop - document.getElementById('viewDragTable').scrollTop;
		}
	}

	if(val=='myFavoritesNew'){
		if (BrowserDetect.browser=="Firefox") {
			document.getElementById(val).style.top = document.getElementById(val).offsetTop + 13 + 'px';
		}
		else{
			document.getElementById(val).style.top = document.getElementById(val).offsetTop + 17 + 'px';
		}
	}
	if(val=='myRecentKPIs'){
		if (BrowserDetect.browser=="Firefox") {
			document.getElementById(val).style.top = document.getElementById(val).offsetTop - 3 + 'px';
			document.getElementById(val).style.left = document.getElementById(val).offsetLeft - 1 + 'px';
		}
	}
	var myTop = 40;
	if (BrowserDetect.browser=="Firefox"){
		myTop = 35;
	}
	if(val == "functionsBar" || val == "gridUtilityBar"){
		document.getElementById(val).style.top = document.getElementById(val).offsetTop + myTop +"px";
	}
	if(val == "dbFunctionsBar"){
		document.getElementById(val).style.top = document.getElementById(val).offsetTop + 35 +"px";
	}


	if(val=='totalCoulmnsScorecard')
	{
	document.getElementById(val).style.left = '300px';
/*		if (document.getElementById('totalCoulmns')){
			document.getElementById(val).style.left = document.getElementById(val).offsetTop - document.getElementById('viewDragTable').scrollTop;
		}*/
	}
	var ddlay = setTimeout("clearTimeout('ddlay');attachEventToExpandSmallPopup()", "100");
}
function invokeCloser(val){}
function closeUtilitys(val){
	if(arcGsearch){
		arcGsearch.gsearchCloseResult("resultText");
	}
	if (BrowserDetect.browser=="Firefox") {
		document.onmousedown = function(event){src=window.event?window.event.srcElement:event.target;
		Element.cleanWhitespace(src.childNodes[0]);
		 if(src.childNodes[0].className=='hdrcell'){if(typeof event.preventDefault != 'undefined') {
		 event.preventDefault();}}};
	}
    if (document.all)
    document.onselectstart = function () { return false; };
	toCloseAll = new Array("actionList","graphContent2PPT", "subcontent2PPT", "topUtilityBarPopup", "utilityBarPopup1", "utilityBarPopup2", "utilityBarPopup3", "menuBarPopup1", "myDashboard", "enablePortletsDiv", "graphFilters", "swapView", "kpiUtilityBar1", "kpiUtilityBar2", "kpiUtilityBar3", "kpiUtilityBar4","kpiUtilityBar5", "functionsBar", "freezeCoulmns", "visibleCoulmns", "totalCoulmns", "orderCoulmns", "drillDown", "drillAccross", "drillDown", "exportOptions", "rankPopup", "updateCols_RANK", "updateCols_COMPLEXRANK", "updateCols_DENSERANK", "updateCols_BUCKET", "updateCols_LEAD", "updateCols_LAG", "updateCols_CUMEDIST", "updateCols_PERCRANK", "easySearch", "freezeColumn", "hideColumn", "unitMeasure", "saveFilterDiv", "myFavorites", "dbFunctionsBar", "allViews", "addDimensionAttribute", "addBaseMeasure", "addComputedMeasures", "gridUtilityBar", "groupingColDiv", "measureFormatColumn", "functionsBarPlanning", "customizeG", "admenuBarPopup1", "viewSeq", "measureSeq", "crosstabCols", "crosstabTotal", "crosstabSort", "attributeCols", "defaultView", "showMeasuresList", "customizeLinkKpi", "myRecentKPIList", "filterSeq", "changeGraph", "graphConfigSettings", "myStoryLine", "selectedAggrColumns", "filterStyleTypeMain", "selectAggregateList", "UtilityPositionList", "QuadrantChart", "totalCoulmnsScorecard", "strategyMapDtlDiv", "hideColumnPPT", "myRecentKPIs", "myFavoritesNew", "customPopUp", "showMeasuersForPDF", "showNewColumnCal", "showGroupMeasures", "changeMeasuresName");
	if(hideFlag!=false || val=="force"){
		for(i=0; i<=toCloseAll.length-1; i++){
			if(globalCloseId != toCloseAll[i] && document.getElementById(toCloseAll[i])){
					document.getElementById(toCloseAll[i]).style.display='none';
			}

			if(globalCloseId != toCloseAll[i] && parent.document.getElementById(toCloseAll[i])){
					parent.document.getElementById(toCloseAll[i]).style.display='none';
			}
		}
		globalCloseId="";
	}else{
		for(i=0; i<=toCloseAll.length-1; i++){
			if(document.getElementById(toCloseAll[i])){
				if(document.getElementById(toCloseAll[i]).style.display!="none"){
					closeFlag=false;
				}
			}

			if(parent.document.getElementById(toCloseAll[i])){
				if(parent.document.getElementById(toCloseAll[i]).style.display!="none"){
					closeFlag=false;
				}
			}
		}
	}
}

//menuseq code methods start #manoj#
function showOnlyPersistUtility(val,val1)
{
	newListArray = val1.split(",");
	allChildsOfUtility = document.getElementById(val).childNodes;
	for(var k=0; k<allChildsOfUtility.length; k++)
	{
		allChildsOfUtility[k].style.display = 'block';
	}
	for(var j=0; j<newListArray.length; j++)
	{
		for(var k=0; k<allChildsOfUtility.length; k++)
		{
			if(allChildsOfUtility[k].id == newListArray[j])
			{
				allChildsOfUtility[k].style.display = 'none';
				allChildsOfUtility[k].childNodes[0].checked = false;
				break;
			}
		}
	}
}


function reOrderMenuList(val, val1, val2, val3, val4){
	var UserDefinedListArray = "";

	var elementToReOrder="";
	var oldList =  new Array();
	var liInnerHTMLStr =  new Array();

	if(val=="menuBarPopup1"){elementToReOrder = "utilityDinamicList1";}
	if(val=="utilityBarPopup1"){elementToReOrder = "utilityDinamicList";}
	if(val=="utilityBarPopup2"){elementToReOrder = "utilityDinamicList2";}
	if(val=="topUtilityBarPopup"){elementToReOrder = "utilityDinamicList3";}
	if(val=="utilityBarPopup3"){elementToReOrder = "utilityDinamicList4";}

		UserDefinedListArray = val3.split(",");
		if(val3 != ""){
			allLi = document.getElementById(elementToReOrder).getElementsByTagName("li");
			for(i=0; i<allLi.length; i++)
			{

				//if(allLi[i].attributes["itemID"].value != "9_module"){
					oldList.push(allLi[i].attributes["itemID"].value);
					liInnerHTMLStr.push(allLi[i]);
				//}
			}
			var innerHtmlStr = "";
			var innerHtmlStrIndividual = "";
			for(k=0; k<UserDefinedListArray.length; k++)
			{
				innerHtmlStrIndividual = "";
				for(j=0; j<oldList.length; j++)
				{
					if(UserDefinedListArray[k] == oldList[j])
					{
						oldList.splice(j,1);
						innerHtmlStrIndividual = liInnerHTMLStr[j].innerHTML;
						liInnerHTMLStr.splice(j,1);
						break;
					}
				}
				if(UserDefinedListArray[k] != "" && UserDefinedListArray[k]!="menuBarConfig"){
					if(UserDefinedListArray[k] != "uti_1_seperator"){
						if(innerHtmlStrIndividual!="")
						innerHtmlStr = innerHtmlStr + "<li itemID='"+UserDefinedListArray[k]+"'>" + innerHtmlStrIndividual + "</li>";
					}else{
						innerHtmlStr = innerHtmlStr  + '<li itemID="uti_1_seperator" style="background-image:url(images/separator4.gif); padding:0px;">&nbsp;</li>';
					}
				}
			}
			//For adding existing items also in to list
			for(k=0; k<oldList.length; k++)
			{
				if(oldList[k] != ""){
					if(oldList[k] != "uti_1_seperator"){
						if(liInnerHTMLStr[k].innerHTML!=""){
						innerHtmlStr = innerHtmlStr + "<li itemID='"+oldList[k]+"'>" + liInnerHTMLStr[k].innerHTML + "</li>";
						val4 = val4 + "," + oldList[k];
						}
					}else{
						innerHtmlStr = innerHtmlStr  + '<li itemID="uti_1_seperator" style="background-image:url(images/separator4.gif); padding:0px;">&nbsp;</li>';
					}
				}
			}
			document.getElementById(elementToReOrder).innerHTML = "";
			document.getElementById(elementToReOrder).innerHTML = innerHtmlStr;

			allLi = document.getElementById(elementToReOrder).getElementsByTagName("li");
			val4 = ","+val4;
			for(i=0; i<allLi.length; i++){
				if(val4.indexOf(","+allLi[i].attributes["itemID"].value) != -1){
					if(val=="menuBarPopup1"){
						allLi[i].childNodes[0].childNodes[0].checked = false;
					}else{
						if(allLi[i].innerHTML != "")
							allLi[i].childNodes[0].checked = false;
					}
				}

			}
		}
}

function reOrderUtilityOnload(val, val1, val2, val3){

	var newList = "";
	var menuList = "";
	var elementToReOrder="";
	if(val=="menuBarPopup1"){elementToReOrder = "utilityDinamicList1";}
	if(val=="utilityBarPopup1"){elementToReOrder = "utilityDinamicList";}
	if(val=="utilityBarPopup2"){elementToReOrder = "utilityDinamicList2";}
	if(val=="topUtilityBarPopup"){elementToReOrder = "utilityDinamicList3";}
	if(val=="utilityBarPopup3"){elementToReOrder = "utilityDinamicList4";}

	allLi = document.getElementById(elementToReOrder).getElementsByTagName("li");

	for(i=0; i<allLi.length; i++){
		if(newList==""){
			newList = allLi[i].attributes["itemID"].value;
		}
		else{
			newList = newList + ","+ allLi[i].attributes["itemID"].value;
		}
	}
	menuList = newList;

	if(val3 != ""){
		//For adding existing items also in to list
		if(val3.split(",").length >= newList.split(",").length){
			newList= "toputi_1_browserLinks,"+val3+",toputi_1_globalLinks";
			menuList =  val3;
		}else{
			newList= "toputi_1_browserLinks,"+newList+",toputi_1_globalLinks";
			menuList = menuList;
		}

	}else{
		newList="toputi_1_browserLinks,"+newList+",toputi_1_globalLinks";
		menuList = menuList;
	}

	//persisting the order in a global variable- ram
	if(val1=="topTop"){
		topTopMenuBarList=menuList;
	}else if(val1=="menuTop"){
		menuTopMenuBarList=menuList;
	}else if(val1=="utilityTop"){
		utilityTopMenuBarList=menuList;
	}else if(val1=="utilityBottom"){
		utilityBottomMenuBarList=menuList;
	}else if(val1=="utilityTopSingle"){
		utilityTopSingleMenuBarList=menuList;
	}

	newListArray = newList.split(",");
	currentArray = new Array();
	currentId = new Array();


	for(m=0; m<document.getElementById(val1).childNodes.length; m++){
		if(document.getElementById(val1).childNodes[m].id){
				if (isNav){
				/*FireFox Fix:: outerHTML not working*/
				currentArray.push(getOuterHTML(document.getElementById(val1).childNodes[m]));
				currentId.push(document.getElementById(val1).childNodes[m].id);
				}
			else if (isIE){
				currentArray.push(document.getElementById(val1).childNodes[m].outerHTML);
				currentId.push(document.getElementById(val1).childNodes[m].id);
				//Added by Manoj for Seprator Issue
					if(val1=="utilityTop"){
						document.getElementById('uti_1_seperator').style.display='block';
						document.getElementById('uti_1_seperator').className = "seperator";
						document.getElementById('uti_1_seperator').removeAttribute("style");
				}
			}

		}
	}
	document.getElementById(val1).innerHTML='';
	for(i=0; i<newListArray.length; i++){
		for(j=0; j<currentId.length; j++){
			if(newListArray[i] == currentId[j])	{
				document.getElementById(val1).innerHTML = document.getElementById(val1).innerHTML + currentArray[j];
			}
		}
	}


	for(j=0; j<currentId.length; j++){
		var ifFound = false;
		if(val1=="menuTop"){

			for(m=0; m<document.getElementById(val1).childNodes.length; m++){
				if(currentId[j] == document.getElementById(val1).childNodes[m].id){
					ifFound = true;
				}
			}
		}
		if(!ifFound){
			if(currentId[j] == val2 || currentId[j] == val || currentId[j] == "menuTop" || currentId[j] == "enablePortlets" || currentId[j] == "utilityViewClose" || currentId[j] == "advancedUtilityViewClose"){
			document.getElementById(val1).innerHTML = document.getElementById(val1).innerHTML + currentArray[j];
		}
	}
	}
	newList = "";
	for(m=0; m<document.getElementById(val1).childNodes.length; m++){
		if(m==0){
			newList = document.getElementById(val1).childNodes[m].id;
		}else{
			newList = newList + "," + document.getElementById(val1).childNodes[m].id;
		}
	}
	//persisting the order in a global variable- ram
	if(val1=="menuTop"){
		menuTopMenuBarList=menuList;
	}

	currentId="";currentArray="";newListArray="";

}

function onLogoutUtilityUnchked(val){
	var unCheckedList = "";
	var elementToReOrder="";
	if(val=="menuBarPopup1"){elementToReOrder = "utilityDinamicList1";}
	if(val=="utilityBarPopup1"){elementToReOrder = "utilityDinamicList";}
	if(val=="utilityBarPopup2"){elementToReOrder = "utilityDinamicList2";}
	if(val=="topUtilityBarPopup"){elementToReOrder = "utilityDinamicList3";}
	if(val=="utilityBarPopup3"){elementToReOrder = "utilityDinamicList4";}

	allLi = document.getElementById(elementToReOrder).getElementsByTagName("li");
	for(i=0; i<allLi.length; i++){
		//var cleanedallLi = allLi[i].cleanWhitespace();
		var cleanedallLi = allLi[i];
		if(val!="menuBarPopup1"){
			if(cleanedallLi.childNodes[0] && cleanedallLi.childNodes[0].checked == false){
				if(unCheckedList == ""){
					unCheckedList = cleanedallLi.childNodes[0].value;
				}
				else{
					unCheckedList = unCheckedList + "," + cleanedallLi.childNodes[0].value;
				}
			}
		}else{
			if(cleanedallLi.childNodes[0] && cleanedallLi.childNodes[0].childNodes[0] && cleanedallLi.childNodes[0].childNodes[0].checked == false){
				if(unCheckedList == ""){
					unCheckedList = cleanedallLi.childNodes[0].childNodes[0].value;
				}
				else{
					unCheckedList = unCheckedList + "," + cleanedallLi.childNodes[0].childNodes[0].value;
				}
			}
		}
	}
	return unCheckedList;
}
//end

function reOrderUtility(val, val1, val2,val3)
{
	var newList = "";
	var menuList = "";
	var elementToReOrder="";
	if(val=="menuBarPopup1"){elementToReOrder = "utilityDinamicList1";}
	if(val=="utilityBarPopup1"){elementToReOrder = "utilityDinamicList";}
	if(val=="utilityBarPopup2"){elementToReOrder = "utilityDinamicList2";}
	if(val=="topUtilityBarPopup"){elementToReOrder = "utilityDinamicList3";}
	if(val=="utilityBarPopup3"){elementToReOrder = "utilityDinamicList4";}
	if(val=="adutilityBarPopup"){elementToReOrder = "adutilityDinamicList";}

	allLi = document.getElementById(elementToReOrder).getElementsByTagName("li");
	for(i=0; i<allLi.length; i++){
		if(newList==""){
			newList = allLi[i].attributes["itemID"].value;
		}
		else{
			newList = newList + ","+ allLi[i].attributes["itemID"].value;
		}
	}
	menuList = newList;
	if(val3 != ""){
		//For adding existing items also in to list
		if(val3.split(",").length >= newList.split(",").length){
			newList= "toputi_1_browserLinks,"+newList+",toputi_1_globalLinks";
			menuList = menuList;
		}else{
			newList= "toputi_1_browserLinks,"+val3+",toputi_1_globalLinks";
			menuList =  val3;
		}

	}else{
		newList="toputi_1_browserLinks,"+newList+",toputi_1_globalLinks";
		menuList = menuList;
	}

	//persisting the order in a global variable- ram
	if(val1=="topTop"){
		topTopMenuBarList=menuList;
	}else if(val1=="utilityTop"){
		utilityTopMenuBarList=menuList;
	}else if(val1=="utilityBottom"){
		utilityBottomMenuBarList=menuList;
	}else if(val1=="utilityTopSingle"){
		utilityTopSingleMenuBarList=menuList;
	}

	newListArray = newList.split(",");
	currentArray = new Array();
	currentId = new Array();
	for(m=0; m<=document.getElementById(val1).childNodes.length -1; m++){
		if(document.getElementById(val1).childNodes[m].id){
				if (isNav){
					/*FireFox Fix:: outerHTML not working*/
				currentArray.push(getOuterHTML(document.getElementById(val1).childNodes[m]));
				currentId.push(document.getElementById(val1).childNodes[m].id);
				}
				else if (isIE){
				currentArray.push(document.getElementById(val1).childNodes[m].outerHTML);
				currentId.push(document.getElementById(val1).childNodes[m].id);
				}
		}
	}
	document.getElementById(val1).innerHTML='';
	for(i=0; i<=newListArray.length-1; i++){
		for(j=0; j<=currentId.length; j++){
			if(newListArray[i] == currentId[j])	{
				document.getElementById(val1).innerHTML = document.getElementById(val1).innerHTML + currentArray[j];
			}
		}
	}
	for(j=0; j<currentId.length; j++){
		var ifFound = false;
		if(val1=="menuTop"){
			for(m=0; m<document.getElementById(val1).childNodes.length; m++){
				if(currentId[j] == document.getElementById(val1).childNodes[m].id){
					ifFound = true;
				}
			}
		}
		if(!ifFound){
			if(currentId[j] == val2 || currentId[j] == val || currentId[j] == "menuTop" || currentId[j] == "enablePortlets" || currentId[j] == "utilityViewClose" || currentId[j] == "advancedUtilityViewClose"){
				document.getElementById(val1).innerHTML = document.getElementById(val1).innerHTML + currentArray[j];
			}
		}
	}

	newList = "";
	for(m=0; m<document.getElementById(val1).childNodes.length; m++){
		if(m==0){
			newList = document.getElementById(val1).childNodes[m].id;
		}else{
			newList = newList + "," + document.getElementById(val1).childNodes[m].id;
		}
	}
	//persisting the order in a global variable- ram
	if(val1=="menuTop"){
		menuTopMenuBarList=menuList;
	}

	currentId="";currentArray="";newListArray="";
}
var expandCllapseFlag = true;
function toggleExpandCollapse()
{
	if(expandCllapseFlag)
	{
		slash_expandall();
		document.getElementById('expandCollapseImage').src="images/icon_kpiutility_collapseTree.gif";
		document.getElementById('expandCollapseImage').alt=generalMsg[67];
		document.getElementById('expandCollapseImage').title=generalMsg[67];
		expandCllapseFlag = false;
	}
	else
	{
		slash_contractall();
		document.getElementById('expandCollapseImage').src="images/icon_kpiutility_expandTree.gif";
		document.getElementById('expandCollapseImage').alt=generalMsg[66];
		document.getElementById('expandCollapseImage').title=generalMsg[66];
		expandCllapseFlag = true;
	}

}

var expandCollapseFlagTree = true;
function toggleExpandCollapseTree(objTreeID)
{
	if(expandCollapseFlagTree)
	{
		objTreeID.openAllItems(0);
		document.getElementById('expandCollapseImageTree').src="images/icon_kpiutility_collapseTree.gif";
		document.getElementById('expandCollapseImageTree').alt=generalMsg[67];
		document.getElementById('expandCollapseImageTree').title=generalMsg[67];
		expandCollapseFlagTree = false;
	}
	else
	{
		objTreeID.closeAllItems(0);
		document.getElementById('expandCollapseImageTree').src="images/icon_kpiutility_expandTree.gif";
		document.getElementById('expandCollapseImageTree').alt=generalMsg[66];
		document.getElementById('expandCollapseImageTree').title=generalMsg[66];
		expandCollapseFlagTree = true;
	}

}
/* UTILITY BAR ENDS */

/*PORTLET FUNC ENDS*/
function swapFilters(val){}
var currButtonClass='';
var currButtonParentClass='';
function onMainButton(div)
{
	currButtonClass = div.className;
	currButtonParentClass = div.parentNode.className;
	div.className='buttonGreyActiveLeft';
	div.parentNode.className='buttonGreyActiveRight_M';
}
function offMainButton(div)
{
	div.className=currButtonClass;
	div.parentNode.className=currButtonParentClass;
}
function onMainButtonBlue(div)
{
	currButtonClass = div.className;
	currButtonParentClass = div.parentNode.className;
	div.className='buttonBlueActiveLeft';
	div.parentNode.className='buttonBlueActiveRight_M';
}
function offMainButtonBlue(div)
{
	div.className=currButtonClass;
	div.parentNode.className=currButtonParentClass;
}

var globalAnalystHeight;

function globalAnalystHeightCheck()
{
	if(null != document.getElementById('utilityBar') && document.getElementById('utilityBar')){
		if(document.getElementById('utilityBar').style.display=='' && document.getElementById('utilityBarSingle').style.display=='')
		{
			globalAnalystHeight = 292;
		}
		if(document.getElementById('utilityBar').style.display=='none' && document.getElementById('utilityBarSingle').style.display=='none')
		{
			globalAnalystHeight = 183;
		}
		if(document.getElementById('utilityBar').style.display=='none' && document.getElementById('utilityBarSingle').style.display=='')
		{
			globalAnalystHeight = 222;
		}
		if(document.getElementById('utilityBar').style.display=='' && document.getElementById('utilityBarSingle').style.display=='none')
		{
			globalAnalystHeight = 253;
		}
	}
}

var resizeFlag = true;

var centerportletHeight=0;
function resizePortlet(val, val1)
{
	defaultHeight = window.screen.height - globalAnalystHeight;
	centerPortlet = document.getElementById(val1);
	if(val == "KPIBrowser" || val == "KPIBrowserMini" || val == "dimensionBrowser" || val == "dimensionBrowserMini")
	{
		resizeFlag = false;
	}
	else
	{
		resizeFlag = true;
	}

	if(resizeFlag)
	{
		if(document.getElementById('treeboxbox_tree'))
		{
			resizeTimer = setTimeout("document.getElementById('treeboxbox_tree').childNodes[0].style.height = centerPortlet.offsetHeight - 110 + 'px'; clearTimeout(resizeTimer);", "100");
		}
		if(document.getElementById('treeboxbox_tree0'))
		{
			resizeTimer = setTimeout("document.getElementById('treeboxbox_tree0').childNodes[0].style.height = centerPortlet.offsetHeight - 110 + 'px'; clearTimeout(resizeTimer);", "100");
		}
		if(document.getElementById('treeboxbox_tree1'))
		{
			resizeTimer = setTimeout("document.getElementById('treeboxbox_tree1').childNodes[0].style.height = centerPortlet.offsetHeight - 110 + 'px'; clearTimeout(resizeTimer);", "100");
		}
		if(document.getElementById('treeboxbox_tree2'))
		{
			resizeTimer = setTimeout("document.getElementById('treeboxbox_tree2').childNodes[0].style.height = centerPortlet.offsetHeight - 110 + 'px'; clearTimeout(resizeTimer);", "100");
		}
		if(document.getElementById('treeboxbox_tree3'))
		{
			resizeTimer = setTimeout("document.getElementById('treeboxbox_tree3').childNodes[0].style.height = centerPortlet.offsetHeight - 110 + 'px'; clearTimeout(resizeTimer);", "100");
		}
		if(document.getElementById('treeboxbox_tree4'))
		{
			resizeTimer = setTimeout("document.getElementById('treeboxbox_tree4').childNodes[0].style.height = centerPortlet.offsetHeight - 110 + 'px'; clearTimeout(resizeTimer);", "100");
		}
		if(document.getElementById('treeboxbox_tree5'))
		{
			resizeTimer = setTimeout("document.getElementById('treeboxbox_tree5').childNodes[0].style.height = centerPortlet.offsetHeight - 110 + 'px'; clearTimeout(resizeTimer);", "100");
		}
		if(document.getElementById('filterTrees'))
		{
			resizeTimer = setTimeout("document.getElementById('filterTrees').childNodes[0].style.height = centerPortlet.offsetHeight - 110 + 'px'; clearTimeout(resizeTimer);", "100");
		}
		if(document.getElementById('langBrowserTree'))
		{
			resizeTimer = setTimeout("document.getElementById('langBrowserTree').childNodes[0].style.height = centerPortlet.offsetHeight - 110 + 'px'; clearTimeout(resizeTimer);", "100");
		}

		resizeTimer = setTimeout("document.getElementById('"+val+"').style.height = centerPortlet.offsetHeight - 5 + 'px'; clearTimeout(resizeTimer);", "100");
	}
	else
	{
		if ( centerPortlet != null ){
		if(centerPortlet.offsetHeight>=defaultHeight)
		{
			if(document.getElementById('KPIBrowser'))document.getElementById('KPIBrowser').style.height=centerPortlet.offsetHeight+ 'px';
			if(document.getElementById('KPIBrowserMini'))document.getElementById('KPIBrowserMini').style.height=centerPortlet.offsetHeight+ 'px';
			if(document.getElementById('dimensionBrowser'))document.getElementById('dimensionBrowser').style.height=centerPortlet.offsetHeight+ 'px';
			if(document.getElementById('dimensionBrowserMini'))document.getElementById('dimensionBrowserMini').style.height=centerPortlet.offsetHeight+ 'px';

			if(document.getElementById('kpiBrowserLayer'))document.getElementById('kpiBrowserLayer').style.height=centerPortlet.offsetHeight - 127 + "px";
			if(document.getElementById('treeboxbox_tree1'))document.getElementById('treeboxbox_tree1').childNodes[0].style.height = centerPortlet.offsetHeight - 100 + "px";
			if(document.getElementById('treeboxbox_tree2'))document.getElementById('treeboxbox_tree2').childNodes[0].style.height = centerPortlet.offsetHeight - 100 + "px";
			if(document.getElementById('treeboxbox_tree3'))document.getElementById('treeboxbox_tree3').childNodes[0].style.height = centerPortlet.offsetHeight - 100 + "px";
			if(document.getElementById('treeboxbox_tree4'))document.getElementById('treeboxbox_tree4').childNodes[0].style.height = centerPortlet.offsetHeight - 100 + "px";
		}
		if(centerPortlet.offsetHeight<=defaultHeight-1)
		{
			if(document.getElementById('KPIBrowser'))document.getElementById('KPIBrowser').style.height=defaultHeight - 10 + "px";
			if(document.getElementById('KPIBrowserMini'))document.getElementById('KPIBrowserMini').style.height=defaultHeight - 10 + "px";
			if(document.getElementById('dimensionBrowser'))document.getElementById('dimensionBrowser').style.height=defaultHeight - 10 + "px";
			if(document.getElementById('dimensionBrowserMini'))document.getElementById('dimensionBrowserMini').style.height=defaultHeight - 10 + "px";

			if(document.getElementById('kpiBrowserLayer'))document.getElementById('kpiBrowserLayer').style.height=defaultHeight - 137 + "px";
			if(document.getElementById('treeboxbox_tree1'))document.getElementById('treeboxbox_tree1').childNodes[0].style.height = defaultHeight - 110 + "px";
			if(document.getElementById('treeboxbox_tree2'))document.getElementById('treeboxbox_tree2').childNodes[0].style.height = defaultHeight - 110 + "px";
			if(document.getElementById('treeboxbox_tree3'))document.getElementById('treeboxbox_tree3').childNodes[0].style.height = defaultHeight - 110 + "px";
			if(document.getElementById('treeboxbox_tree4'))document.getElementById('treeboxbox_tree4').childNodes[0].style.height = defaultHeight - 110 + "px";
		}
		if(isIE6 && typeof document.getElementById("ie6FixContainer")!='undefined')
		{
			if(document.getElementById('dataGridContainer').style.display=="none")
			  document.getElementById("ie6FixContainer").style.display='block';
			else
			  document.getElementById("ie6FixContainer").style.display='none';
		}

	}

	if (document.getElementById(val) != null ){
	document.getElementById(val).style.zIndex= 100;
}
	}
}
/*PORTLET FUNC ENDS*/

/*KPI*/
var currKPIUtilityClass='';
function onKPIUtilityBar(div)
{
	currKPIUtilityClass = div.className;

	div.className='kpiUtilityBarActive';
}
function offKPIUtilityBar(div)
{
	div.className=currKPIUtilityClass;
}

var currKPIUtilityClass1='';
function onKPIUtilityBar1(div)
{
	currKPIUtilityClass1 = div.className;

	div.className='kpiUtilityBarActive1';
}
function offKPIUtilityBar1(div)
{
	div.className=currKPIUtilityClass1;
}

var currKPIUtilityClassPlane='';
function onKPIUtilityBarPlane(div)
{
	currKPIUtilityClassPlane = div.className;

	div.className='kpiUtilityBarActivePlane';
}
function offKPIUtilityBarPlane(div)
{
	div.className=currKPIUtilityClassPlane;
}

var currKPIUtilityClassBrowser='';
function onKPIUtilityBarBrowser(div)
{
	currKPIUtilityClassBrowser = div.className;

	div.className='kpiBrowserButtonActive';
}
function offKPIUtilityBarBrowser(div)
{
	div.className=currKPIUtilityClassBrowser;
}

function swapGraphTblView(graphDiv,obj){
	Element.cleanWhitespace(obj);
  	if(obj.childNodes[0].src.indexOf("icon_kpiutility_tabView")>=0){
			document.getElementById('chartView_'+graphDiv).style.display='none';
			document.getElementById('tabularView_'+graphDiv).style.display='block';
			obj.childNodes[0].src="images/iconSmallBarGraph.gif";
			obj.childNodes[0].title=generalMsg[74];
			if(obj.childNodes[2]){obj.childNodes[2].innerHTML ='Swap to Graph View';}
  	}else{
			document.getElementById('chartView_'+graphDiv).style.display='block';
			document.getElementById('tabularView_'+graphDiv).style.display='none';
			obj.childNodes[0].src="images/icon_kpiutility_tabView.gif";
			obj.childNodes[0].title=generalMsg[75];
			if(obj.childNodes[2]){obj.childNodes[2].innerHTML ='Swap to Tabular View';}
  	}return;
}

function hideGraphUtilities(graphDiv){
	if(document.getElementById('pinGraph_'+graphDiv) && document.getElementById('changeGraph_'+graphDiv)){
	 if(document.getElementById('tabularView_'+graphDiv).style.display=='block'){
			document.getElementById('pinGraph_'+graphDiv).style.display='none';
		document.getElementById('changeGraph_'+graphDiv).style.display='none';
	}else{
		   document.getElementById('pinGraph_'+graphDiv).style.display='block';
		   document.getElementById('changeGraph_'+graphDiv).style.display='block';
	 }
	}
	if($('kpiGraphUtilities'))showMoreUtilities('kpiGraphUtilities','menuUtilityBar4','rightGraphUtilityView');
}

function showGraphUtilities(graphDiv){
	if(document.getElementById('pinGraph_'+graphDiv) && document.getElementById('changeGraph_'+graphDiv)){
		if(pinGraphFlag==true)
			document.getElementById('pinGraphAct_'+graphDiv).style.display='block';
		else
			document.getElementById('pinGraph_'+graphDiv).style.display='block';
		document.getElementById('changeGraph_'+graphDiv).style.display='block';
	}
}

var tabValue = "";
function showHidePanel(val, val1, val2)
{
	if(document.getElementById(val).style.display=='block')
	{
		document.getElementById(val).style.display='none';
		document.getElementById('viewsKPIBrowser').checked=false;
		eval("document.getElementById('"+val+"Mini').style.display='block'");
		document.getElementById(val1).style.width='35px';
		document.getElementById(val2).style.marginLeft='40px';
		if(mygrid!=null && mygrid._fake!=null){
			mygrid._fake._correctSplit();
		}

		if(document.planIframeId)
		{
		  if(document.planIframeId.document.getElementById('innerTableforFrame'))
		  {
		  	tableWidth = document.planIframeId.document.getElementById('innerTableforFrame').parentNode.offsetWidth;
		  	document.planIframeId.document.getElementById('innerTableforFrame').style.width = tableWidth-10+"px";
		  }
		}
		//if(document.getElementById('level1')){document.getElementById('level1').style.width = document.getElementById('level1').offsetWidth + 350;}
	}
	else
	{
		if(document.planIframeId)
		{
		  if(document.planIframeId.document.getElementById('innerTableforFrame'))
		  {
		  	tableWidth = document.planIframeId.document.getElementById('innerTableforFrame').parentNode.offsetWidth;
		  	document.planIframeId.document.getElementById('innerTableforFrame').style.width = 540+"px";
		  }
		}

		document.getElementById(val).style.display='block';
		document.getElementById('viewsKPIBrowser').checked=true;
		eval("document.getElementById('"+val+"Mini').style.display='none'");
		document.getElementById(val1).style.width='220px';
		document.getElementById(val2).style.marginLeft='225px';

		if(mygrid!=null && mygrid._fake!=null){
			mygrid.setSizes();
			mygrid._fake._correctSplit();
		}
		if(document.getElementById('filtersPortletMMDiv'))
		{
			if(document.getElementById('filtersPortletMMDiv').style.display=='none')
			{
				document.getElementById('filtersPortletMMDiv').style.display = 'block';
				//if(document.getElementById('level1')){document.getElementById('level1').style.width = document.getElementById('level1').offsetWidth - 350;}
				document.getElementById('filtersPortletMMDiv').style.display = 'none';
			}
			/*else
			{alert(document.getElementById('level1').offsetWidth);
				if(document.getElementById('level1')){document.getElementById('level1').style.width = document.getElementById('level1').offsetWidth - 350;}
			alert(document.getElementById('level1').offsetWidth);
			}*/
		}
	}
	if($('kpiReportUtilities'))showMoreUtilities('kpiReportUtilities','menuUtilityBar3','rightReportUtilityView');
	if($('kpiUtilities'))showMoreUtilities('kpiUtilities','menuUtilityBar2','rightUtilityView');
	if($('kpiGraphUtilities'))showMoreUtilities('kpiGraphUtilities','menuUtilityBar4','rightGraphUtilityView');
	if($("kpi_dhtmlx_tabs_1")){
		if($("kpi_dhtmlx_tabs_1").parentNode.offsetWidth> getDisplayedTabLength("kpi_dhtmlx_tabs_1"))
		{
			$("customScrollTab_1").style.display='none';
			$("spacerTab_1").style.width=$("kpi_dhtmlx_tabs_1").parentNode.offsetWidth-getDisplayedTabLength("kpi_dhtmlx_tabs_1")+"px";
		}
	}

if(document.getElementById('mygrid')&& document.getElementById('KUtilityBar') && document.getElementById('coverUpDiv_GridUtil')){
   	document.getElementById('coverUpDiv_GridUtil').style.width = document.getElementById('KUtilityBar').offsetWidth - 20 + "px";
   }
}

var layoutId_KPI = 0;
var layoutOrder_KPI = "";
var dimMesFil = false;

function closeLoadingAfterTree(){}

function showHidePanelLayer(val)
{
	if(arcGsearch)
	{
		arcGsearch.gsearchCloseResult("resultText");
	}

	if(dimMesFil==false)
	{
		tree1.setImagePath("dhtmlX/codebaseTree/imgs/dimension/");
		tree1.enableDragAndDrop(true);
		tree1.enableDragAndDropScrolling(true);
		tree1.setDragHandler(maf);
		tree1.enableKeyboardNavigation(true);
		tree1.enableKeySearch(true);
		tree1.enableSmartXMLParsing(true);
		tree1.enableDistributedParsing(true,10,50);
		tree1.loadXML("out_xml.jsp?action=dimTree");
		tree1.enableAutoTooltips(false);
		tree1.allTree.onmouseover = function(e){ e=e||event;  showNmFltrToolTip('kpiNamedFilterPop',e);};

		tree2.setImagePath("dhtmlX/codebaseTree/imgs/measures/");
		tree2.enableDragAndDrop(true);
		tree2.enableDragAndDropScrolling(true);
		tree2.setDragHandler(maf);
		tree2.enableKeyboardNavigation(true);
		tree2.enableKeySearch(true);
		tree2.enableSmartXMLParsing(true);
		tree2.enableDistributedParsing(true,10,50);
		tree2.loadXML("out_xml.jsp?action=measureTree");
		tree2.enableAutoTooltips(false);
		tree2.allTree.onmouseover = function(e){ e=e||event; showNmFltrToolTip('kpiNamedFilterPop',e);};

		if(tree3) tree3.deleteChildItems(0);
		tree3.setImagePath("dhtmlX/codebaseTree/imgs/savedFilter/");
		tree3.enableDragAndDrop(true);
		tree3.enableDragAndDropScrolling(true);
		tree3.setDragHandler(maf);
		tree3.enableMultiLineItems(true);
		tree3.enableKeyboardNavigation(true);
		tree3.enableKeySearch(true);
		tree3.enableSmartXMLParsing(true);
		tree3.loadXML("out_xml.jsp?action=namedFilters");
		tree3.enableAutoTooltips(false);
		tree3.attachEvent("onXLE",closeLoadingAfterTree);
		tree3.allTree.onmouseover = function(e){ e=e||event; showNmFltrToolTip('kpiNamedFilterPop',e);};

		tree4.setImagePath("dhtmlX/codebaseTree/imgs/expression/");
		tree4.enableDragAndDrop(true);
		tree4.enableDragAndDropScrolling(true);
		tree4.setDragHandler(maf);
		tree4.enableKeyboardNavigation(true);
		tree4.enableSmartXMLParsing(true);
		tree4.deleteChildItems(0);
		tree4.loadXML("out_xml.jsp?action=TemplateTree");
		tree4.enableAutoTooltips(false);
		tree4.allTree.onmouseover = function(e){ e=e||event; showNmFltrToolTip('kpiNamedFilterPop',e);};

		dimMesFil=true;
	}
	if(document.getElementById(val).style.display=='block')
	{
		document.getElementById(val).style.display='none';
		if(document.getElementById('filterSectionButton') && layoutId_KPI == "1")
		{
			document.getElementById('filterSectionButton').style.paddingRight = '0px';
		}

		if((layoutId_KPI == "2") && (layoutOrder_KPI=="2_3_1" || layoutOrder_KPI=="3_2_1")){
			if(document.getElementById('filterSectionButtonTop')){
				document.getElementById('filterSectionButtonTop').style.paddingRight = '0px';
			}
			if(document.getElementById('filterSectionButton')){
				document.getElementById('filterSectionButton').style.paddingRight = '0px';
			}
		}

		if(document.getElementById('filterSectionButtonTop') && layoutId_KPI == "1")
		{
			document.getElementById('filterSectionButtonTop').style.paddingRight = '0px';
		}

		if(document.getElementById('dataTableContainer'))
		{
			document.getElementById('dataTableContainer').style.width = '100%';
		}
		eval("document.getElementById('"+val+"Mini').style.display='block'");

		if(document.getElementById('customIFrame'))
		{
			document.getElementById('customIFrame').style.width = "100%";
		}
	}
	else
	{
		document.getElementById(val).style.display='block';
		if(isIE6){
		var rtpnlfx=document.createElement("iframe");
		rtpnlfx.width=document.getElementById(val).offsetWidth;
		rtpnlfx.height=document.getElementById(val).offsetHeight;
		rtpnlfx.frameborder="0";
		rtpnlfx.style.position="absolute";
		rtpnlfx.style.top="27px";
		rtpnlfx.style.left="0px";
		rtpnlfx.style.zIndex="9";
		rtpnlfx.style.backgroundColor="#ffffff";
		document.getElementById(val).appendChild(rtpnlfx);
		rtpnlfx=null;
		}
		eval("document.getElementById('"+val+"Mini').style.display='none'");

		if(document.getElementById('filterSectionButton') && layoutId_KPI == "1")
		{
			document.getElementById('filterSectionButton').style.paddingRight = '290px';
			document.getElementById('filterSectionButtonTop').style.paddingRight = '290px';
		}

		if(document.getElementById('customIFrame'))
		{
			document.getElementById('customIFrame').style.width = document.getElementById('customIFrame').offsetWidth - 285 + "px";
		}

		if((layoutId_KPI == "2") && (layoutOrder_KPI=="2_3_1" || layoutOrder_KPI=="3_2_1")){
			if(document.getElementById('filterSectionButton')){
				document.getElementById('filterSectionButton').style.paddingRight = '290px';
				document.getElementById('filterSectionButtonTop').style.paddingRight = '290px';
			}
		}

	}
}

function showHideGraphLayer(val,val1,val2)
{
	if(document.getElementById(val).style.display=='block')
	{
		document.getElementById(val).style.display='none';
		document.getElementById('portletLeftPopup2').style.marginRight = val1+'px';
		eval("document.getElementById('"+val+"Mini').style.display='block'");
		if(val == "dimensionBrowserGra" && !isNav){
			resizePortlet(val+'Mini', 'portletLeftPopup2');
		}

	}
	else
	{
		document.getElementById(val).style.display='block';
		document.getElementById('portletLeftPopup2').style.marginRight = val2+'px';
		eval("document.getElementById('"+val+"Mini').style.display='none'");
		if(val == "dimensionBrowserGra" && !isNav){
			resizePortlet(val, 'portletLeftPopup2');
		}
	}
}

function closeKPIUtility(val, val1)
{
	if(document.getElementById('portletLeft'))
	{
		if(document.getElementById('kpiCenter_ShowHide').style.marginLeft=='' || document.getElementById('kpiCenter_ShowHide').style.marginLeft=='235px' || document.getElementById('kpiCenter_ShowHide').style.marginLeft=='0px')
		{
			if(val=='close')
			{
				document.getElementById('KPIBrowser').style.display='none';
				document.getElementById('kpiCenter_ShowHide').style.marginLeft='0px';
			}
			else
			{
				document.getElementById('KPIBrowser').style.display='block';
				document.getElementById('kpiCenter_ShowHide').style.marginLeft='235px';
			}
		}
		else
		{
			val1.checked=false;
		}
	}
	else
	{
		val1.checked=false;
	}
}

function escLayer(e)
{
      var kC  = (window.event) ?    // MSIE or Firefox?
                 event.keyCode : e.keyCode;
      var Esc = (window.event) ?
                27 : e.DOM_VK_ESCAPE // MSIE : Firefox
      if(kC==Esc)
         showHidePanelLayer('dimensionBrowser');

}

widthArray = new Array();
dockedWidth = 0;
//kpiGridWidthDivision_1 = 0;

function dockPortlet(val, val1)
{
	//numberOfCols = parseInt(document.getElementById('gridVisibleMeasures').innerHTML)+1;

	numberOfCols = parseInt(mygrid.getColumnsNum());
	if(document.getElementById('portletLeft').style.display!='none')
	{
		//kpiGridWidthDivision_1 = kpiGridWidthDivision;
		//kpiGridWidthDivision = kpiGridWidthDivision + 265;
		document.getElementById('portletLeft').style.display='none';
		document.getElementById('filtersPortlet').style.display='none';
		document.getElementById('tabularViewPortlet').style.display='none';
		document.getElementById('kpiRight_ShowHide').style.display='none';

		document.getElementById('kpiTitleSpan').style.position='absolute';
		document.getElementById('kpiTitleSpan').style.top=document.getElementById('kpiTitleSpan').offsetTop-15;
		document.getElementById('kpiTitleSpan').style.left='5px';
		document.getElementById('kpiTitleSpan').style.marginRight='5px';

		if(document.getElementById('headerViewPortlet').style.display != 'none'){
		document.getElementById('headerViewPortlet').style.position='absolute';
			if(layoutId_KPI == "2"){
				document.getElementById('headerViewPortlet').style.top=document.getElementById('headerViewPortlet').offsetTop+14;
			}else{
				document.getElementById('headerViewPortlet').style.top=document.getElementById('headerViewPortlet').offsetTop-5;
			}
		document.getElementById('headerViewPortlet').style.left='5px';
		document.getElementById('headerViewPortlet').style.marginRight='5px';
		}
		document.getElementById('dataGridContainer').style.position='absolute';
		if(document.getElementById('headerViewPortlet').style.display == "none"){
			document.getElementById('dataGridContainer').style.top=document.getElementById('dataGridContainer').offsetTop+15;
		}else{
			document.getElementById('dataGridContainer').style.top=document.getElementById('dataGridContainer').offsetTop+47;
		}
		document.getElementById('dataGridContainer').style.left='5px';
		document.getElementById('dataGridContainer').style.marginRight='5px';

		dockedWidth = document.getElementById('dataGridContainer').offsetWidth;

		document.getElementById('kpiAfter').style.marginTop=document.getElementById('dataGridContainer').offsetHeight + "px";

		val1.src= "images/icon_kpiutility_undock.gif";
		val1.alt=generalMsg[70];
		val1.title=generalMsg[70];
		if($('kpiReportUtilities'))showMoreUtilities('kpiReportUtilities','menuUtilityBar3','rightReportUtilityView');

		if(typeof(ribbon_MenuActivatedFlag) && !ribbon_MenuActivatedFlag)
		{
				if (BrowserDetect.browser!="Firefox") {
					if(displayUtilityIconName == '2'){
						$('menuUtilityBar3').style.marginTop = '234px';
						$('exportOptions').style.marginTop = '285px';
					}else{
						$('menuUtilityBar3').style.marginTop = '';
						$('exportOptions').style.marginTop = '';
					}
				}else{
					if(displayUtilityIconName < '2'){
						$('menuUtilityBar3').style.marginTop = '';
						$('exportOptions').style.marginTop = '';
					}else{
						$('menuUtilityBar3').style.marginTop = '189px';
						$('exportOptions').style.marginTop = '265px';
					}

				}
				$('exportOptions').style.marginLeft = -7+'px';

		}

		if($('kpiUtilityBar5')){
			$('kpiUtilityBar5').style.marginTop = '172px';
			$('kpiUtilityBar5').style.marginLeft = -5+'px';
		}

		//totalWidth = 0;
		for(i=0; i<=numberOfCols; i++)
		{
			widthArray.push(mygrid.getColWidth(i));
			//totalWidth = totalWidth+mygrid.getColWidth(i);
		}
		/*applyedNewWidth = 0;
		if(document.getElementById('dataGridContainer').offsetWidth>=totalWidth)
		{
			newtotalWidth = totalWidth-widthArray[0]-widthArray[1];
			newDivWidth = document.getElementById('dataGridContainer').offsetWidth-widthArray[0]-widthArray[1];
			applyedNewWidth =((newDivWidth-newtotalWidth)/numberOfCols)-1;
		if(!dhtmlxGridWidthPersonalize && !dhtmlxGridOrderPersonalize && numberOfCols<=10){
			applyedNewWidth = 0;
			applyedNewWidth =((document.getElementById('dataGridContainer').offsetWidth)-50)/(numberOfCols-1);
			for(i=1; i<numberOfCols; i++)
			{
				mygrid.setColWidth(i, applyedNewWidth);
			}
		}
		for(i=0; i<numberOfCols; i++)
		{
			mygrid.setColWidth(i, widthArray[i]+applyedNewWidth);
		}*/
		if(numberOfCols<=10){
			applyedNewWidth = 0;
			applyedNewWidth =((document.getElementById('dataGridContainer').offsetWidth)+35)/(numberOfCols);
			for(i=1; i<numberOfCols; i++)
			{
				mygrid.setColWidth(i, applyedNewWidth);
			}
		}
	}
	else
	{
		//kpiGridWidthDivision = kpiGridWidthDivision_1;
		document.getElementById('portletLeft').style.display='block';
		if(isWorkFlowKPI=='no'){
			document.getElementById('filtersPortlet').style.display='block';
		}
		if(document.getElementById('tabularViewPortlet').style.display == 'block'){
		document.getElementById('tabularViewPortlet').style.display='block';
		}
		document.getElementById('tabularViewPortlet').style.display='block';
		document.getElementById('kpiRight_ShowHide').style.display='block';

		document.getElementById('kpiTitleSpan').style.position='';
		document.getElementById('kpiTitleSpan').style.top='';
		document.getElementById('kpiTitleSpan').style.left='';
		document.getElementById('kpiTitleSpan').style.marginRight='';
		document.getElementById('headerViewPortlet').style.position='';
		document.getElementById('headerViewPortlet').style.top='';
		document.getElementById('headerViewPortlet').style.left='';
		document.getElementById('headerViewPortlet').style.marginRight='';

		document.getElementById('dataGridContainer').style.position='';
		document.getElementById('dataGridContainer').style.left='';
		document.getElementById('dataGridContainer').style.marginRight='';
		document.getElementById('dataGridContainer').style.top='';

		document.getElementById('kpiAfter').style.marginTop='10px';

		val1.src= "images/icon_kpiutility_dock.gif";
		val1.alt=generalMsg[71];
		val1.title=generalMsg[71];
		if($('kpiReportUtilities'))showMoreUtilities('kpiReportUtilities','menuUtilityBar3','rightReportUtilityView');

		if(typeof(ribbon_MenuActivatedFlag) && !ribbon_MenuActivatedFlag)
		{
			if (BrowserDetect.browser=="Explorer") {
				$('menuUtilityBar3').style.marginTop = '';
				$('exportOptions').style.marginTop = '';
			}else{
				$('menuUtilityBar3').style.marginTop = '-9px';
			}
			$('exportOptions').style.marginLeft = '';
		}
		if($('kpiUtilityBar5')){
			$('kpiUtilityBar5').style.marginTop = '';
			$('kpiUtilityBar5').style.marginLeft = '';
		}

		/*for(i=0; i<numberOfCols; i++)
		{
			mygrid.setColWidth(i, widthArray[i]);
		if(!dhtmlxGridWidthPersonalize && !dhtmlxGridOrderPersonalize && numberOfCols<=10){
			for(i=0; i<numberOfCols; i++)
			{
				mygrid.setColWidth(i, widthArray[i]);
			}
		}*/
		if(!dhtmlxGridWidthPersonalize && !dhtmlxGridOrderPersonalize && numberOfCols<=10){
			for(i=0; i<numberOfCols; i++)
			{
				mygrid.setColWidth(i, widthArray[i]);
			}
		}
		widthArray.clear();
		dockedWidth = 0;
		document.getElementById('dataGridContainer').style.width = '';
	}

	doresize('notHome');
    if(document.getElementById('KUtilityBar') && document.getElementById('coverUpDiv_GridUtil')){
   	document.getElementById('coverUpDiv_GridUtil').style.width = document.getElementById('KUtilityBar').offsetWidth - 20 + "px";
   }
	/*if(mygrid!=null){
		mygrid.setSizes();
	}*/

	if(mygrid._fake!=null){
		mygrid._fake._correctSplit();
	}
	if(tmpDataGrid!=null)
		tmpDataGrid.setSizes();
}

var customIFrameTempHeight;
function dockPortletPDF(val, val1)
{
	if(document.getElementById('portletLeft').style.display!='none')
	{
		customIFrameTempHeight = document.getElementById('customIFrame').offsetHeight;
		document.getElementById('portletLeft').style.display='none';
		document.getElementById('filtersPortlet').style.display='none';
		document.getElementById('tabularViewPortlet').style.display='none';
		document.getElementById('kpiRight_ShowHide').style.display='none';
		document.getElementById('arcMenu').style.display='none';
		document.getElementById('dimensionBrowserMini').style.display='none';

		document.getElementById('kpiTitleSpan').style.position='absolute';
		document.getElementById('kpiTitleSpan').style.top=document.getElementById('kpiTitleSpan').offsetTop;
		document.getElementById('kpiTitleSpan').style.left='5px';
		document.getElementById('kpiTitleSpan').style.marginRight='5px';

		document.getElementById('kpiAfter').style.paddingTop=document.getElementById('dataGridContainer').offsetHeight + 45 + "px";

		document.getElementById('dataGridContainer').style.position='absolute';
		document.getElementById('dataGridContainer').style.top=document.getElementById('dataGridContainer').offsetTop+30;
		document.getElementById('dataGridContainer').style.left='5px';
		document.getElementById('dataGridContainer').style.marginRight='5px';
		document.getElementById('dataGridContainer').style.height = '445px';
		document.getElementById('customIFrame').style.height = '445px';

		val1.src= "images/icon_kpiutility_undock.gif";
		val1.alt=generalMsg[70];
		val1.title=generalMsg[70];
	}
	else
	{
		document.getElementById('portletLeft').style.display='block';
		document.getElementById('filtersPortlet').style.display='block';
		document.getElementById('tabularViewPortlet').style.display='block';
		document.getElementById('kpiRight_ShowHide').style.display='block';
		document.getElementById('arcMenu').style.display='block';
		document.getElementById('dimensionBrowserMini').style.display='block';

		document.getElementById('kpiTitleSpan').style.position='';
		document.getElementById('kpiTitleSpan').style.top='';
		document.getElementById('kpiTitleSpan').style.left='';
		document.getElementById('kpiTitleSpan').style.marginRight='';

		document.getElementById('kpiAfter').style.paddingTop='';

		document.getElementById('dataGridContainer').style.position='';
		document.getElementById('dataGridContainer').style.left='';
		document.getElementById('dataGridContainer').style.marginRight='';
		document.getElementById('dataGridContainer').style.top='';

		document.getElementById('dataGridContainer').style.height = customIFrameTempHeight;
		document.getElementById('customIFrame').style.height= customIFrameTempHeight;
		customIFrameTempHeight='';

		val1.src= "images/icon_kpiutility_dock.gif";
		val1.alt=generalMsg[71];
		val1.title=generalMsg[71];
		if(document.getElementById("KPIBrowser").style.display=='none') {
			document.getElementById("KPIBrowser").style.display='block';
			showHidePanel('KPIBrowser', 'portletLeft', 'kpiCenter_ShowHide');
		}
	}
	doresize('notHome');
   if(document.getElementById('KUtilityBar') && document.getElementById('coverUpDiv_GridUtil')){
   	document.getElementById('coverUpDiv_GridUtil').style.width = document.getElementById('KUtilityBar').offsetWidth - 20 + "px";
   }
}

function maxmin(val, val1)
{
	Element.cleanWhitespace(val1);
	if(eval("document.getElementById('"+val+"MMDiv').style.display=='block'"))
	{
		eval("document.getElementById('"+val+"MMDiv').style.display='none'");
		if(val1.tagName!="IMG"){
			val1.childNodes[0].src='images/icon_kpiutility_maximize.gif';
			val1.childNodes[0].alt=generalMsg[64];
			val1.childNodes[0].title=generalMsg[64];
		}
		else{
			val1.src='images/icon_kpiutility_maximize.gif';
			val1.alt=generalMsg[64];
			val1.title=generalMsg[64];
		}
	}
	else
	{
		eval("document.getElementById('"+val+"MMDiv').style.display='block'");
		if(val1.tagName!="IMG"){
			val1.childNodes[0].src='images/icon_kpiutility_minimize.gif';
			val1.childNodes[0].alt=generalMsg[65];
			val1.childNodes[0].title=generalMsg[65];
		}
		else {
			val1.src='images/icon_kpiutility_minimize.gif';
			val1.alt=generalMsg[65];
			val1.title=generalMsg[65];
		}
	}
	doresize('notHome');
}

var gridHeight="";
function summaryPageMaxmin(val, val1)
{
		if(eval("document.getElementById('"+val+"').style.display==''"))
		{
			eval("document.getElementById('"+val+"').style.display='none'");
			val1.src='images/icon_kpiutility_maximize.gif';
			val1.alt=generalMsg[64];
			val1.title=generalMsg[64];
			if(gridHeight)gridHeight=300;
		}
		else
		{
			eval("document.getElementById('"+val+"').style.display=''");
			val1.src='images/icon_kpiutility_minimize.gif';
			val1.alt=generalMsg[65];
			val1.title=generalMsg[65];
			if(gridHeight)gridHeight=185;
		}
}

function summaryPageMaxminWithGridChange(val, val1, val2, val3, val4, dxgrid)
{
	if(dxgrid)
	{
		if(eval("document.getElementById('"+val+"').style.display==''"))
		{
			eval("document.getElementById('"+val+"').style.display='none'");
			val1.src='images/icon_kpiutility_maximize.gif';
			val1.alt=generalMsg[64];
			val1.title=generalMsg[64];
			dxgrid.enableAutoHeight(true,val3,true); dxgrid.setSizes();
			maximized = true;
		}
		else
		{
			eval("document.getElementById('"+val+"').style.display=''");
			val1.src='images/icon_kpiutility_minimize.gif';
			val1.alt=generalMsg[65];
			val1.title=generalMsg[65];
			dxgrid.enableAutoHeight(true,val4,true); dxgrid.setSizes();
			maximized = false;
		}
	}
}
/*KPI ENDS*/


/*DRAG DROP*/
function verticalOnly(item) {
	item.toolManDragGroup.verticalOnly()
}

function speak(id, what) {
	var element = document.getElementById(id);

	element.innerHTML = 'Clicked ' + what;
}

function saveOrder(item) {

	var group = item.toolManDragGroup
	var list = group.element.parentNode
	var id = list.getAttribute("id")
	if (id == null) return
	group.register('dragend', function() {
		ToolMan.cookies().set("list-" + id,
				junkdrawer.serializeList(list), 365)
	})
}

function showHideUtility(liVal, val1)
{
	if(liVal.checked)
	{
		document.getElementById(liVal.value).style.display="";

		var heightM = 0;
		if(val1=='topTop' || val1=="admenuTop")
			heightM = document.getElementById(val1).parentNode.offsetHeight;
		else if(val1=='menuTop')
			heightM = document.getElementById(val1).parentNode.offsetHeight-4;
		else
			heightM = document.getElementById(val1).offsetHeight;

		if(heightM>=34)
		{
			document.getElementById(liVal.value).style.display="none";
			if(val1 =="topTop")
			{
				alert(generalMsg[0]);
			}
			if(val1 =="menuTop" || val1 =="admenuTop")
			{
				alert(generalMsg[1]);
			}
			if(val1 =="utilityTop" || val1 =="utilityBottom" )
			{
				alert(generalMsg[2]);
			}
			if(val1 =="utilityTopSingle")
			{
				alert(generalMsg[92]);
			}

			liVal.checked = false;
		}
		hideFlag=false;
	}
	else
	{
		document.getElementById(liVal.value).style.display="none";
		hideFlag=false;
	}
	return true;
}
/*DRAG DROP ENDS*/


/*POP UP*/
function onBlurFunc()
{
	if(document.getElementById('popUpFrame') && document.getElementById('popUpFrame').style.display=='block')
	{
		document.getElementById('popUpFrame').focus();
	}
}

function invokePopup(val, val2, val3, val4, val5)
{
	if(document.getElementById('winLoader')){document.getElementById('winLoader').style.display='block';}

	var allTopDivs= parent.document.getElementsByTagName("div");
	for(i=0; i<allTopDivs.length; i++)
	{
		if(allTopDivs[i].className=="buttonBlueRight_M"  || allTopDivs[i].className=="buttonBlueActiveRight_M"){
			allTopDivs[i].style.display='none';
		}
	}
	if(BrowserDetect.OS=='Mac' && BrowserDetect.browser=='Firefox'){
		var allEmbedObj = null;
		if(parent.portalFrame){
			allEmbedObj = parent.portalFrame.document.getElementsByTagName("embed");
		}
		else if($('portalFrame') && $('portalFrame').src.indexOf("fromAdmin")> -1){
			allEmbedObj = portalFrame.document.getElementsByTagName("embed");
		}
		else{
			allEmbedObj = parent.document.getElementsByTagName("embed");
		}
		for(i=0; i<allEmbedObj.length; i++){
			allEmbedObj[i].style.display='none';
		}
	}

	document.getElementById('popUpFrame').setAttribute("onblur", onBlurFunc);
	document.getElementById('popUpFrame').setAttribute("onkeydown", fnBlock_F11);
	document.getElementById('popUpFrame').src ="";
	document.getElementById('popUpIframe').style.position = 'absolute';
	document.getElementById('popUpIframe').style.top = '0px';
	document.getElementById('popUpIframe').style.left = '0px';
	document.getElementById('popUpIframe').style.width = '100%';
	document.getElementById('popUpIframe').style.backgroundColor = '#ffffff';

	if (BrowserDetect.browser=="Firefox")
	{
		document.getElementById('popUpIframe').style.height = window.innerHeight + window.scrollMaxY + "px";
		document.getElementById('popUpIframe').style.opacity = '0.7';
		document.getElementById('popUpIframe').style.display='block';
	}
	else if (BrowserDetect.browser=="Explorer")
	{
		document.getElementById('popUpIframe').style.height = (document.body.clientHeight) + "px";
		document.getElementById('popUpIframe').style.filter = 'alpha(opacity=70)';
		document.getElementById('popUpIframe').style.display='block';
	}

	if(val3!="*,*")
	{
		val3 = val3.split(",");
		document.getElementById('popUp').style.top = val3[0] +"px";
		document.getElementById('popUp').style.left = val3[1] +"px";
	}
	else
	{
		document.getElementById('popUp').style.top = (window.screen.height/2)  +"px";
		document.getElementById('popUp').style.left = (window.screen.width/2)  -  val4 +"px";
	}

	if (BrowserDetect.browser!="Firefox"){
		invokePop_dragDown("popUp","popupNav");
	}

	if (BrowserDetect.browser=="Firefox"){
		 window.scroll(0,val3[0]);
	}



	document.getElementById('popUp').style.display='block';
	document.getElementById('popUp').style.zIndex='999';
	document.getElementById('popUp').style.width = val5 +"%";
	document.getElementById('popUp').focus();
	val2=(val2.indexOf("?")>=0)?(val2.split("?")[0]+"?timeStamp="+new Date().getUTCMilliseconds()+"&"+val2.split("?")[1]):(val2+"?timeStamp="+new Date().getUTCMilliseconds());
	document.getElementById('popUpFrame').src =val2;
	document.getElementById('popUpFrame').height =val4 +"px";
	document.getElementById('popUpName').innerHTML = val;
}
////
var oldX=null;var oldY=null;var dx=null;var dy=null;var mvholder=false;
function invokePop_dragDown(oldContainerId,ifrmcntrId){
var dvlayer=document.createElement("div");
	dvlayer.style.position = 'absolute';
	dvlayer.id="iframefix";
	dvlayer.style.top = '0px';
    dvlayer.style.left = '0px';
	dvlayer.style.width = '100%';
	dvlayer.style.backgroundColor = '#ffffff';
	dvlayer.style.height = (document.body.clientHeight) + "px";
	dvlayer.style.filter = 'alpha(opacity=10)';
	dvlayer.style.zIndex='990';
	document.body.appendChild(dvlayer);
	dvlayer=null;
	document.getElementById(ifrmcntrId).previousSibling.onmousedown=function(e){invokePop_dragStart(oldContainerId);}
	document.getElementById(ifrmcntrId).previousSibling.childNodes[0].style.cursor="text";
}
function invokePop_dragStart(oldContainerId){
	 src=window.event?window.event.srcElement:e.target;
 	 if(src.className!="popupHeader" && src.className!="popupHeader1")return;
	 evtx=window.event?event.x:e.clientX;
	 evty=window.event?event.y:e.clientY;
	 oldX=evtx;oldY=evty;
	 if(document.getElementById("popUp_new1"))document.body.removeChild(document.getElementById("popUp_new1"))
	 var dv=document.createElement("div");
	 dv.id="popUp_new1";
	 dv.style.border="2px dashed #808080";
	 dv.style.cursor="move";
	 dv.style.zIndex='9999999';
	 dv.style.width=document.getElementById(oldContainerId).offsetWidth+"px";
	 dv.style.height=(document.getElementById(oldContainerId).offsetHeight)+"px";
	 dv.style.position="absolute";
	 dv.style.left=document.getElementById(oldContainerId).style.left;
	 dv.style.top=document.getElementById(oldContainerId).style.top;
	 dv.style.display="";
	 dx = parseInt(dv.style.left+0); dy = parseInt(dv.style.top+0);
	 document.body.appendChild(dv);
	 mvholder=true;
	 dv=null;
	document.onmouseup=function(e){invokePop_dragStop(window.event?event:e,oldContainerId,"popUp_new1");}
	document.onmousemove=function(e){invokePop_Move(window.event?event:e,oldContainerId,"popUp_new1");}
	var oldy=null;
function invokePop_Move(e,oldContainerId,placeHolderId){
	if(mvholder && document.getElementById(placeHolderId)){
 	  evtx=parseInt(window.event?event.x:e.clientX);
 	  evty=(window.event?event.y:e.clientY);
      document.getElementById(oldContainerId).style.display="none";
	  d=document.getElementById(placeHolderId);
	  d.style.left = dx + evtx - oldX + "px";
      d.style.top  = dy + evty - oldY + "px";
	}
}
function invokePop_dragStop(e,oldContainerId,placeHolderId){
		if(document.getElementById(placeHolderId)){
			if(document.getElementById(oldContainerId)){
			    document.getElementById(oldContainerId).style.display="block";
				 blockHeightPosition=parseInt(document.body.scrollHeight);
			     uptodragable=parseInt(evty+document.body.parentNode.scrollTop);
			     if(uptodragable<blockHeightPosition){
				   document.getElementById(oldContainerId).style.top=parseInt(document.getElementById(placeHolderId).style.top)+"px";
				 }else{
				   document.getElementById(oldContainerId).style.top=parseInt(blockHeightPosition-100)+"px";
				 }
				 if(document.getElementById(placeHolderId).offsetLeft>0)
				   document.getElementById(oldContainerId).style.left=parseInt(document.getElementById(placeHolderId).style.left)+"px";
				 else
				   document.getElementById(oldContainerId).style.left="0px";
				 if((document.getElementById(placeHolderId).offsetLeft+parseInt(document.getElementById(placeHolderId).offsetWidth/2))>(document.body.offsetWidth+400)){
					 document.getElementById(oldContainerId).style.left=(document.body.offsetWidth-150)+"px";
				 }else{
				 	 document.getElementById(oldContainerId).style.left=parseInt(document.getElementById(placeHolderId).style.left)+"px";
				 }
			}
			document.getElementById(placeHolderId).style.display="none";
			document.body.removeChild(document.getElementById(placeHolderId));
			mvholder=false;oldX=null;oldY=null;dx=null;dy=null;
		}
    document.detachEvent("onmousemove", invokePop_Move);
    document.detachEvent("onmouseup",   invokePop_dragStop);
}
}
////


function killPopup(){
	if(document.getElementById('winLoader')){document.getElementById('winLoader').style.display='none';}
	var allTopDivs= parent.document.getElementsByTagName("div");
	for(i=0; i<allTopDivs.length; i++)
	{
		if(allTopDivs[i].className=="buttonBlueRight_M"  || allTopDivs[i].className=="buttonBlueActiveRight_M"){
			allTopDivs[i].style.display='block';
		}
	}
	if(BrowserDetect.OS=='Mac' && BrowserDetect.browser=='Firefox'){

		if(parent.portalFrame){
			var allEmbedObj = parent.portalFrame.document.getElementsByTagName("embed");
		}
		else if($('portalFrame') && $('portalFrame').src.indexOf("fromAdmin")> -1){
			var allEmbedObj = portalFrame.document.getElementsByTagName("embed");
		}
		else{
			var allEmbedObj = parent.document.getElementsByTagName("embed");
		}
		for(i=0; i<allEmbedObj.length; i++){
					allEmbedObj[i].style.display='block';
		}
	}
	document.getElementById('popUpFrame').src ="about:blank";
	document.getElementById('popUpFrame').removeAttribute("onblur");
	document.getElementById('popUpIframe').style.display='none';
	document.getElementById('popUp').style.left = '0px';
	document.getElementById('popUp').style.top = '-2000px';
	document.getElementById('popUp').style.width = '100px';
	document.getElementById('popUp').style.height = '';
	document.getElementById('popUpName').innerHTML = "";
	document.getElementById('popUp').style.display='none';
	document.getElementById('popupFrame').src="blank.html";
	document.getElementById('mandatorySection').innerHTML="";
	document.getElementById('poupButtons').innerHTML="";
	document.body.removeChild(document.getElementById("iframefix"));
}

function killExpressionWindow()
{
	if (popUpFrame.expressionFrm.expressions.value != "" )
	{
		var con = confirm(generalMsg[3]);
		if ( con )
		{
			killPopup();
		}
	}
	else{
		killPopup();
	}
}

function escPopup(e){
      var kC  = (window.event) ?    // MSIE or Firefox?
                 event.keyCode : e.keyCode;
      var Esc = (window.event) ?
                27 : e.DOM_VK_ESCAPE // MSIE : Firefox
      if(kC==Esc) {
         var closeCheck = confirm(generalMsg[4]);
         if(closeCheck)
         {
             if(document.getElementById('popUpFrame')!=null)
	          killPopup();
	         else
	          parent.killPopup();
	     }
      }
}

var currTopIconsClass=''
function onTopIcons(div)
{
	currTopIconsClass = div.className;
	div.className='topIconsActive';
}
function offTopIcons(div)
{
	div.className=currTopIconsClass;
}
/*POP UP ENDS*/


/*CUSTOM TAB*/
var globalKPIGraphVal="graphKPIView1"
function customTab1(val)
{
	document.getElementById(val).style.display='';
	document.getElementById(globalKPIGraphVal).style.display='none';
	eval("document.getElementById('"+val+"Con').style.display=''");
	eval("document.getElementById('"+globalKPIGraphVal+"Con').style.display='none'");
	globalKPIGraphVal=val;
}

function customTab(val)
{
	closeCustomTab(val);
	document.getElementById(val).style.display='';
	eval("document.getElementById('"+val+"Con').style.display=''");
	if(val=='kpiView')
	{
		document.getElementById('kpiTopMenu').style.display='none';
		document.getElementById('graphTopMenu').style.display='';
		document.getElementById('kpiSummary').style.display='none';
		document.getElementById('graphSummary').style.display='';
		resizePortlet('kpiGraphBrowser', 'portletSecond');
	}
	if(val=='graphView')
	{
		document.getElementById('kpiTopMenu').style.display='';
		document.getElementById('graphTopMenu').style.display='none';
		document.getElementById('kpiSummary').style.display='';
		document.getElementById('graphSummary').style.display='none';
		resizePortlet('kpiGraphBrowser', 'portletSecond');
	}
}

function closeCustomTab(val)
{

		if(val=='metricsView' || val=='dimensionView' || val=='measureView' || val=='filterView' || val=='gaView'  || val=='aggregateView' || val=='measureGrpView' || val=='globalView' || val=='recentDimMeasView')
		{
		if(document.getElementById('metricsView'))
		{
			document.getElementById('metricsView').style.display='none';
			document.getElementById('metricsViewCon').style.display='none';
		}
		if(document.getElementById('dimensionView'))
		{
			document.getElementById('dimensionView').style.display='none';
			document.getElementById('dimensionViewCon').style.display='none';
		}
		if(document.getElementById('measureView'))
		{
			document.getElementById('measureView').style.display='none';
			document.getElementById('measureViewCon').style.display='none';
		}
		if(document.getElementById('filterView'))
		{
			document.getElementById('filterView').style.display='none';
			document.getElementById('filterViewCon').style.display='none';
		}
		if(document.getElementById('aggregateView'))
		{
			document.getElementById('aggregateView').style.display='none';
			document.getElementById('aggregateViewCon').style.display='none';
		}
		if(document.getElementById('measureGrpView'))
		{
			document.getElementById('measureGrpView').style.display='none';
			document.getElementById('measureGrpViewCon').style.display='none';
		}
		if(document.getElementById('globalView'))
		{
			document.getElementById('globalView').style.display='none';
			document.getElementById('globalViewCon').style.display='none';
		}
		if(document.getElementById('recentDimMeasView'))
		{
			document.getElementById('recentDimMeasView').style.display='none';
			document.getElementById('recentDimMeasViewCon').style.display='none';
		}
		if(document.getElementById('scoreCardView'))
		{
			document.getElementById('scoreCardView').style.display='none';
			document.getElementById('scoreCardViewCon').style.display='none';
		}
	}

	if(document.getElementById('portletsView'))
	{
		document.getElementById('portletsView').style.display='none';
		document.getElementById('portletsViewCon').style.display='none';
	}
	if(document.getElementById('graphKPIView'))
	{
		document.getElementById('graphKPIView').style.display='none';
		document.getElementById('graphKPIViewCon').style.display='none';
	}
	if(document.getElementById('gaView'))
	{
		document.getElementById('gaView').style.display='none';
		document.getElementById('gaViewCon').style.display='none';
	}
	if(document.getElementById('kpiGraphView'))
	{
		document.getElementById('kpiGraphView').style.display='none';
		document.getElementById('kpiGraphViewCon').style.display='none';
	}
	if(document.getElementById('graphView'))
	{
		document.getElementById('graphView').style.display='none';
		document.getElementById('graphViewCon').style.display='none';
	}
	if(document.getElementById('kpiView'))
	{
		document.getElementById('kpiView').style.display='none';
		document.getElementById('kpiViewCon').style.display='none';
	}

	if(document.getElementById('scoreCardView'))
	{
		document.getElementById('scoreCardView').style.display='none';
		document.getElementById('scoreCardViewCon').style.display='none';
	}

	if(val=='personalizeView' || val=='defaultView')
	{
		if(document.getElementById('personalizeView'))
		{
			document.getElementById('personalizeView').style.display='none';
			document.getElementById('personalizeViewCon').style.display='none';
		}
		if(document.getElementById('defaultView'))
		{
			document.getElementById('defaultView').style.display='none';
			document.getElementById('defaultViewCon').style.display='none';
		}
	}
}

function customTabMobile(val)
{
	closeAllCustomTabMobile();
	document.getElementById(val).style.display='block';
	eval("document.getElementById('"+val+"Con').style.display=''");
}

function closeAllCustomTabMobile()
{
	if(document.getElementById('graphMobView'))
	{
		document.getElementById('graphMobView').style.display='none';
		document.getElementById('graphMobViewCon').style.display='none';
	}
	if(document.getElementById('kpiMobView'))
	{
		document.getElementById('kpiMobView').style.display='none';
		document.getElementById('kpiMobViewCon').style.display='none';
	}
	if(document.getElementById('alertMobView'))
	{
		document.getElementById('alertMobView').style.display='none';
		document.getElementById('alertMobViewCon').style.display='none';
	}
	if(document.getElementById('qaMobView'))
	{
		document.getElementById('qaMobView').style.display='none';
		document.getElementById('qaMobViewCon').style.display='none';
	}
}
/*CUSTOM TAB ENDS*/


/*MK TREE*/
var currTreeClass='';
function onMktree(div)
{
	currTreeClass = div.className;
	div.className = 'liHover';
}
function offMktree(div)
{
	div.className=currTreeClass;
}
/*MK TREE ENDS*/



/*Custom Drag option*/
	function s_control(){
		this._drag=function(sourceHtmlObject,dhtmlObject,targetHtmlObject){
			targetHtmlObject.style.backgroundColor="";
			if(targetHtmlObject.id == 'assignMetricsContent' && sourceHtmlObject.parentObject.label =='Graph Portlet')
			{
				document.getElementById('assignMetrics').style.display='none';
				document.getElementById('assignMetrics1').style.display='block';
			}
			if(targetHtmlObject.id == 'assignMetrics1Content'  && sourceHtmlObject.parentObject.parentObject.label =='Graphs')
			{
				document.getElementById('assignMetrics1').style.display='none';
				document.getElementById('assignMetrics2').style.display='block';
			}
			//targetHtmlObject.value=sourceHtmlObject.parentObject.label;
		}

		this._dragIn=function(htmlObject,shtmlObject){
				htmlObject.style.backgroundColor="#fffacd";
				return htmlObject;
		}

		this._dragOut=function(htmlObject){
			htmlObject.style.backgroundColor="";
			return this;
		}

	}

	function clickedNode(itemId){
		itemId = itemId.split(".");
		if(itemId[0]=='2')
		{
			tree2.enableDragAndDrop('temporary_disabled');
		}
		else
		{
			tree2.enableDragAndDrop(true);
		}
    }
/*Custom Drag option Ends*/

/*DHTML GRID Extended*/

function checkAllCheckboxes(val){}

/*DHTML GRID Extended ENDS*/

/*Mobile Mgmt*/
function deleteDragTableRowforMobileParent(val, val1)
{
	var totRows = 0;
	var idMatched = false;

	tblObj = document.getElementById(val1).childNodes[0].childNodes[1];
	for(i=0;i<tblObj.rows.length; i++)
	{
		if(tblObj.childNodes[i].id==val && !idMatched)
		{
			idMatched = true;
		}

		if(idMatched)
		{
			if(tblObj.childNodes[i].title=='')
			{
				totRows = totRows +1;
			}
			else
			{
				if(tblObj.childNodes[i].id!=val)
				{
					break;
				}
			}
		}
	}

	for(i=0;i<tblObj.rows.length; i++)
	{
		if(tblObj.childNodes[i].id==val)
		{
			tblObj.deleteRow(tblObj.childNodes[i].rowIndex-1);
			toDelRI = tblObj.childNodes[i].rowIndex -1;

			for(j=0;j<totRows; j++)
			{
				tblObj.deleteRow(tblObj.childNodes[i].rowIndex -1);
			}
		}
	}
}

function deleteDragTableRowforMobile(val, val1, val2)
{
	if(val.parentNode.parentNode.parentNode.rows.length>=2)
	{
		val.parentNode.parentNode.parentNode.deleteRow(val.parentNode.parentNode.rowIndex -1);
	}
	if(val1)
	{
		val2 = parseInt(val2);
		//tree1.insertNewItem(val2,val2,val1,0,0,0,0,"");
	}
}

function addDragTableRowforMobileHead(val, val1, val2, val3)
{
	var addClass="";
	var headerFlag=0;
	var rowFlag=0;

	for(i=0;i<val1.childNodes[0].childNodes[1].rows.length; i++)
	{
		if(val1.childNodes[0].childNodes[1].childNodes[i].id == val2)
		{
			headerFlag = headerFlag + 1;
		}
	}

	if(headerFlag==0)
	{
		treeText = val3.getItemText(val2);

		addClass = "tblRow3";

		newRowPN = val1.childNodes[0].insertRow(val1.childNodes[0].rows.length);
		newRowPN.setAttribute('id',val2);
		newRowPN.setAttribute('title',treeText);

		newCellPN1 = document.createElement("td");
		newCellPN1.setAttribute("className", addClass);
		newCellPN1.setAttribute("align", "center");
		newCellPN1.setAttribute("width", "3%");
		newCellPN1.innerHTML = '<a href="javascript:;" onclick="deleteDragTableRowforMobileParent(\''+val2+'\', \''+val1.id+'\')"><img src="images/icon_deleteSmall.gif" alt="Delete" title="Delete" border="0" /></a>';

		newCellPN2 = document.createElement("td");
		newCellPN2.setAttribute("className", addClass);
		newCellPN2.setAttribute("width", "24%");
		newCellPN2.innerHTML = treeText;

		newCellPN3 = document.createElement("td");
		newCellPN3.setAttribute("className", addClass);
		newCellPN3.setAttribute("width", "73%");
		newCellPN3.innerHTML = "-";

		newRowPN.appendChild(newCellPN1);
		newRowPN.appendChild(newCellPN2);
		newRowPN.appendChild(newCellPN3);
	}
	headerFlag=0;
}

function addDragTableRowforMobile(val, val1, val2, val3)
{
	var addClass="";
	var headerFlag=0;
	var rowFlag=0;
	treeText = val3.getItemText(val2);
	treeParentID = val3.getParentId(val2);
	treeParentIDText = val3.getItemText(treeParentID);
	for(i=0;i<val1.childNodes[0].childNodes[1].rows.length; i++)
	{
		if(val1.childNodes[0].childNodes[1].childNodes[i].id == val3.getParentId(val2))
		{
			headerFlag = headerFlag + 1;
		}
	}

	if(headerFlag==0 && treeParentIDText!="")
	{
		addClass = "tblRow3";

		newRowPN = val1.childNodes[0].insertRow(val1.childNodes[0].rows.length);
		newRowPN.setAttribute('id',treeParentID);
		newRowPN.setAttribute('title',treeParentIDText);

		newCellPN1 = document.createElement("td");
		newCellPN1.setAttribute("className", addClass);
		newCellPN1.setAttribute("align", "center");
		newCellPN1.setAttribute("width", "3%");
		newCellPN1.innerHTML = '<a href="javascript:;" onclick="deleteDragTableRowforMobileParent(\''+treeParentID+'\', \''+val1.id+'\')"><img src="images/icon_deleteSmall.gif" alt="Delete" title="Delete" border="0" /></a>';

		newCellPN2 = document.createElement("td");
		newCellPN2.setAttribute("className", addClass);
		newCellPN2.setAttribute("width", "24%");
		newCellPN2.innerHTML = treeParentIDText;

		newCellPN3 = document.createElement("td");
		newCellPN3.setAttribute("className", addClass);
		newCellPN3.setAttribute("width", "73%");
		newCellPN3.innerHTML = "-";

		newRowPN.appendChild(newCellPN1);
		newRowPN.appendChild(newCellPN2);
		newRowPN.appendChild(newCellPN3);
	}
	headerFlag=0;

	for(i=0;i<val1.childNodes[0].childNodes[1].rows.length; i++)
	{
		if(val1.childNodes[0].childNodes[1].childNodes[i].id==val2)
		{
			rowFlag = rowFlag + 1;
		}
	}

	if(rowFlag==0)
	{
		for(i=0;i<val1.childNodes[0].childNodes[1].rows.length; i++)
		{
			if(val1.childNodes[0].childNodes[1].childNodes[i].id == val3.getParentId(val2))
			{
				if(val1.childNodes[0].rows.length%2 == 1)
				{
					addClass = "tblRow2";
				}
				else
				{
					addClass = "tblRow1";
				}

				newRowIndex = val1.childNodes[0].childNodes[1].childNodes[i].rowIndex +1;
				newRow = val1.childNodes[0].insertRow(newRowIndex);
				newRow.setAttribute('id',val2);

				newCell1 = document.createElement("td");
				newCell1.setAttribute("className", addClass);
				newCell1.setAttribute("align", "center");
				newCell1.setAttribute("width", "3%");
				newCell1.innerHTML = '<a href="javascript:;" onclick="deleteDragTableRowforMobile(this,\''+val+'\', \''+val2+'\')"><img src="images/icon_deleteSmall.gif" alt="Delete" title="Delete" border="0" /></a>';

				newCell2 = document.createElement("td");
				newCell2.setAttribute("className", addClass);
				newCell2.setAttribute("width", "24%");
				newCell3 = document.createElement("td");
				newCell3.setAttribute("className", addClass);
				newCell3.setAttribute("width", "73%");
				newCell3.innerHTML = treeText;

				newRow.appendChild(newCell1);
				newRow.appendChild(newCell2);
				newRow.appendChild(newCell3);
			}

			if(val3.getParentId(val2)==0)
			{
				addClass = "tblRow3";

				newRowPN = val1.childNodes[0].insertRow(val1.childNodes[0].rows.length);
				newRowPN.setAttribute('id',treeParentID);
				newRowPN.setAttribute('title',treeParentIDText);

				newCellPN1 = document.createElement("td");
				newCellPN1.setAttribute("className", addClass);
				newCellPN1.setAttribute("align", "center");
				newCellPN1.setAttribute("width", "3%");
				newCellPN1.innerHTML = '<a href="javascript:;" onclick="deleteDragTableRowforMobileParent(\''+treeParentID+'\', \''+val1.id+'\')"><img src="images/icon_deleteSmall.gif" alt="Delete" title="Delete" border="0" /></a>';

				newCellPN2 = document.createElement("td");
				newCellPN2.setAttribute("className", addClass);
				newCellPN2.setAttribute("width", "24%");
				newCellPN2.innerHTML = treeParentIDText;

				newCellPN3 = document.createElement("td");
				newCellPN3.setAttribute("className", addClass);
				newCellPN3.setAttribute("width", "73%");
				newCellPN3.innerHTML = "-";

				newRowPN.appendChild(newCellPN1);
				newRowPN.appendChild(newCellPN2);
				newRowPN.appendChild(newCellPN3);
			}
		}
	}
	rowFlag=0;

	if (document.all)
	document.onselectstart =
	function () { return true; };
}

function addMobileMetrics(val, val1, val2, val3)
{
	var addClass="";
	var table = val1.childNodes[0];
	var headerFlag=true;

	for(i=0;i<table.rows.length;i++){
		if(table.rows[i].id == val2){
			headerFlag = false;
		}
	}
	if(headerFlag){
		newRow = table.insertRow(table.rows.length);
		newRow.setAttribute('id',val2);
		newRow.setAttribute('title',val);

		if(table.rows.length%2 == 1)
		{
			addClass = "tblRow1";
		}
		else
		{
			addClass = "tblRow2";
		}

		newCell1 = document.createElement("td");
		newCell1.setAttribute("className", addClass);
		newCell1.setAttribute("align", "center");
		newCell1.setAttribute("width", "96%");
		newCell1.innerHTML = '<a href="javascript:;" onclick="deleteDragTableRow(this,\''+val+'\', \''+val2+'\')"><img src="images/icon_deleteSmall.gif" alt="'+publishLabel[6]+'" title="'+publishLabel[6]+'" border="0" /></a>';
		newCell2 = document.createElement("td");
		newCell2.setAttribute("className", addClass);
		newCell1.setAttribute("width", "4%");
		newCell2.innerHTML = val;

		newRow.appendChild(newCell1);
		newRow.appendChild(newCell2);
	}
	headerFlag=0;
}

function deleteDragTableRow(val, val1, val2)
{
	if(val.parentNode.parentNode.parentNode.rows.length>=2)
	{
		val.parentNode.parentNode.parentNode.deleteRow(val.parentNode.parentNode.rowIndex);
	}
}

function saveMobileConfig(modifyCreate){
		var frm = $(popUpFrame.addMobileMgmtFrm);
		var userId = $("userId");
		if(userId == null|| userId.value == null || userId.value == ""){
			alert(generalMsg[5]);
			killPopup();
			return true;
		}

		var graphTable = $(popUpFrame.dataGridGraph);
		var kpiTable = $(popUpFrame.dataGridKPI);
		var alertTable = $(popUpFrame.dataGridAlert);
		var qaTable = $(popUpFrame.dataGridQA);

		var menuMatricsStr = "";
		for(i=1;i<graphTable.rows.length;i++){
			menuMatricsStr = menuMatricsStr + "," + graphTable.rows[i].id;
		}
		for(i=1;i<kpiTable.rows.length;i++){
			menuMatricsStr = menuMatricsStr + "," + kpiTable.rows[i].id;
		}
		for(i=1;i<alertTable.rows.length;i++){
			menuMatricsStr = menuMatricsStr + "," + alertTable.rows[i].id;
		}
		for(i=1;i<qaTable.rows.length;i++){
			menuMatricsStr = menuMatricsStr + "," + qaTable.rows[i].id;
		}
		if(menuMatricsStr.indexOf(",") != -1){
			menuMatricsStr=menuMatricsStr.substr(1);
		}

		var DBMetrics = "";
		for( i = 0; i < frm.radioMobileDash.length; i++ ){
			if( frm.radioMobileDash[i].checked == true ){
				DBMetrics = frm.radioMobileDash[i].value;
				break;
			}
		}

		var DBMetricsTable = null;
		var DBMetricsStr = "";
		if(DBMetrics == "yes"){
			DBMetricsTable = $(popUpFrame.assignMetricsTable);
			for(i=1;i<DBMetricsTable.rows.length;i++){
				DBMetricsStr = DBMetricsStr + "," + DBMetricsTable.rows[i].id;
			}
			if(DBMetricsStr.indexOf(",") != -1){
				DBMetricsStr=DBMetricsStr.substr(1);
			}
		}

		if(DBMetrics == "yes" && DBMetricsStr == ""){
			document.getElementById("mandatorySection").innerHTML ="<font style='color:red'>"+ generalMsg[6]+"</font>" ;
			return;
		}
		if(menuMatricsStr == ""){
			document.getElementById("mandatorySection").innerHTML ="<font style='color:red'>"+ generalMsg[7]+"</font>" ;
			return;
		}

		var url="arcmobile";
		var params = "";
		if(modifyCreate == "create"){
			params = "action=saveUserConfig&userId="+userId.value+"&DBMetricSel="+DBMetricsStr+"&menuMetricSel="+menuMatricsStr;
		}else{
			params = "action=modifyUserConfig&userId="+userId.value+"&DBMetricSel="+DBMetricsStr+"&menuMetricSel="+menuMatricsStr;
		}
		var myAjax = new Ajax.Request(url,
			{
			method: 'post',
			parameters: params,
			onComplete: updateColumns
			});
	}

	function updateColumns(orgreq){
		orgreq.responseText.evalScripts();
	}
/*Mobile Ends*/

/*Alert Mgmt*/
	function showRecurr(val1){
	var url = "arcui?nav_action=getServerTime";
		var myAjax = new Ajax.Request(url,
			{
				method: 'post',
				onComplete:function(orgreq){
					orgreq.responseText.evalScripts();
					showRecurrOld(val1);
				}
			});
	}
	function showRecurrOld(val){
		closeRecurr();
		if(val!="" && document.getElementById(val)){
			document.getElementById(val).style.display='';
		}

		var startHoursObj = null;
		var startMinsObj = null;
		var etlCkhObj = document.getElementById('etlChk');
		if(document.getElementById('startHours')!=null && document.getElementById('dhrs') == null){
			startHoursObj = document.getElementById('startHours');
		}

		if(document.getElementById('dhrs')!=null && document.getElementById('startHours') == null){
			startHoursObj = document.getElementById('dhrs');
		}

		if(document.getElementById('startMins')!=null && document.getElementById('dmins') == null){
			startMinsObj = document.getElementById('startMins');;
		}

		if(document.getElementById('dmins')!=null && document.getElementById('startHours') == null){
			startMinsObj = document.getElementById('dmins');
		}

		if(val=='daily' || val=='weekly' || val=='monthly' || val=='oneTime'){
			var currdate = currDateObj;
			var curHrs = '';
			var curMins ='';
			if((startHoursObj==null || startHoursObj.value=='' || (startHoursObj.value=='00' && !etlCkhObj.checked)) && (startMinsObj ==null || startMinsObj.value=='' || (startMinsObj.value=='00' && !etlCkhObj.checked))){
				if(parseInt(currdate.getMinutes()+2)>=59){
					if(parseInt(currdate.getHours()+1)>24){
						curHrs = parseInt(currdate.getHours()+1)-24;
					}else{
						curHrs = parseInt(currdate.getHours()+1);
					}
					curMins = (parseInt(currdate.getMinutes()+2)-59);
				}else{
					curMins = (parseInt(currdate.getMinutes()+2));
					curHrs = parseInt(currdate.getHours());
				}

				if(parseInt(curHrs)>0 && parseInt(curHrs)<9){
					startHoursObj.value = '0'+curHrs;
				}else if(startHoursObj!=null){
					startHoursObj.value = curHrs;
				}

				if(parseInt(curMins)>0 && parseInt(curMins)<9){
					startMinsObj.value = '0'+curMins;
				}else{
					startMinsObj.value = curMins;
				}
			}
		}
	}

	function closeRecurr(){
		if(document.getElementById('daily')){
			document.getElementById('daily').style.display='none';
		}

		if(document.getElementById('weekly')){
			document.getElementById('weekly').style.display='none';
		}

		if(document.getElementById('monthly')){
			document.getElementById('monthly').style.display='none';
		}

		if(document.getElementById('oneTime')){
			document.getElementById('oneTime').style.display='none';
		}
	}

	function showRecipients(val){
		closeRecipients();
		if(val!="" && document.getElementById(val)){
			document.getElementById(val).style.display='block';
		}
	}

	function closeRecipients(){
		if(document.getElementById('roleListing')){
			document.getElementById('roleListing').style.display='none';
		}
		if(document.getElementById('userListing')){
			document.getElementById('userListing').style.display='none';
		}
		if(document.getElementById('externalID')){
			document.getElementById('externalID').style.display='none';
		}
	}

	function highLightSelected(val)
	{
		allHighLightNone(val);
		val.className='tblRowSelected';
	}

	function allHighLightNone(val)
	{
		allTR=val.parentNode.getElementsByTagName("tr");
		for(i=0; i<=allTR.length-1; i++)
		{
			allTR[i].className='';
		}
	}

	function checkRule(val, val1)
	{
		if(val1.checked=="0")
		{
			val1.src= 'images/item_chk1.gif';
			val1.checked= '1';
			document.getElementById(val).style.display='block';
		}
		else
		{
			val1.src= 'images/item_chk0.gif';
			val1.checked= '0';
			document.getElementById(val).style.display='none';
		}
	}
/*Alert Mgmt ENDS*/

/*Filters TREE*/
function convertToCombo(val, val1)
{
	val1Array=val1.split(",");
	innerHTMLS='<select class="inputField" onclick="if(this.selectedIndex!=0){convertToCombo1(this, this.value, \''+val1+'\')}"><option selected=selected>Select</option>';
	for(i=0; i<=val1Array.length-1; i++)
	{
		innerHTMLS = innerHTMLS + '<option value=\''+val1Array[i]+'\'>'+val1Array[i]+'</option>';
	}
	innerHTMLS = innerHTMLS + '</select>';
	val.parentNode.innerHTML = innerHTMLS;
}

function convertToCombo1(val, val1, val2)
{
	val.parentNode.innerHTML='<a href="javascript:;" onclick="convertToCombo(this,\''+val2+'\')">'+val1+'</a>';
}

function convertToComboList(val, val1)
{
	val1Array=val1.split(",");
	innerHTMLS='<select class="inputField" size="3" multiple="multiple" ondblclick="if(this.selectedIndex!=0){convertToComboList1(this, this.value, \''+val1+'\')}">';
	for(i=0; i<=val1Array.length-1; i++)
	{
		innerHTMLS = innerHTMLS + '<option value=\''+val1Array[i]+'\'>'+val1Array[i]+'</option>';
	}
	innerHTMLS = innerHTMLS + '</select>';
	val.parentNode.innerHTML = innerHTMLS;
}

function convertToComboList1(val, val1, val2)
{
	val.parentNode.innerHTML='<a href="javascript:;" onclick="convertToComboList(this,\''+val2+'\')">'+val1+'</a>';
}

function checkBoxes(val1)
{
	if(val1.checked=="0")
	{
		val1.src= 'images/item_chk1.gif';
		val1.checked= '1';
	}
	else
	{
		val1.src= 'images/item_chk0.gif';
		val1.checked= '0';
	}
}
/*Filters TREE ENDS*/

/*Expresson Builder*/
var currentExpVal;
function expBuilder(val)
{
	currentExpVal = document.getElementById('builderExpression');
	if(currentExpVal.value=="Double click on coulmns / operators to build the expression.")
	{
		currentExpVal.value = "";
		currentExpVal.value = currentExpVal.value  + "";
	}
	if(val.name!="operator")
	{
		currentExpVal.value = currentExpVal.value +" "+ val.value; //val.options[val.selectedIndex].text;
		countclik2(currentExpVal);
		currentExpVal.value = currentExpVal.value  + "";
	}
	else
	{
		currentExpVal.value = currentExpVal.value+" " + val.value;
		currentExpVal.value = currentExpVal.value  + "";
	}
}
/**********************************************************************************************************/
var currentExpVal2;
function expBuilderForExpression(val)
{
	currentExpVal2 = document.getElementById('expressionsArea');
	if(currentExpVal2.value=="Double click on coulmns / operators to build the expression.")
	{
		currentExpVal2.value = "";
		currentExpVal2.value = currentExpVal2.value  + "";
	}

	if(val.name!="operator")
	{
		var params = "expressionValue="+encodeURIComponent(val.value);
		var url="arcui?nav_action=getExpTextAction";
		new Ajax.Request(url,{method: 'post',parameters: params,onComplete: showResponseForExpTextAction});
	}
	else
	{
		currentExpVal2.value = currentExpVal2.value+" " + val.value;
		currentExpVal2.value = currentExpVal2.value  + "";
	}
}
/**********************************************************************************************************/
function showResponseForExpTextAction(originalRequest){
	if(document.getElementById("expressionsArea")){
		if(currentExpVal2.value=="")
			currentExpVal2.value = ''+originalRequest.responseText;
		else
			currentExpVal2.value = ''+currentExpVal2.value+" "+originalRequest.responseText;
		countclik(currentExpVal2);

	}
}
/**********************************************************************************************************/
function resetExpBuilder()
{
	currentExpVal2 =  document.getElementById('builderExpression');
	currentExpVal2.value = "";
	currentExpVal = document.getElementById('expressionsArea');
	currentExpVal.value = "";
	document.getElementById('expressionsArea').select();

	myObject=new iObject();
	myObject.i=0;
	myObject2=new iObject();
	myObject2.i=0;
	store_text=new Array();
	store_text[0]="";
	/*******************For Hidden Variable*************************************/
	myObject21=new iObject();
	myObject21.i=0;
	myObject22=new iObject();
	myObject22.i=0;
	store_text2=new Array();
	store_text2[0]="";

	arrUNREDO = new Array();
	arrUNREDO[0]="";
	arrUNREDO2 = new Array();
	arrUNREDO2[0]="";
}

/*Expresson Builder ENDS*/

/*Cross Tab / Graph pub*/
function deleteDragTableRow(val, val1, val2)
{
	if(val.parentNode.parentNode.parentNode.rows.length>=2)
	{
		val.parentNode.parentNode.parentNode.deleteRow(val.parentNode.parentNode.rowIndex);
	}
}

function addDragTableRowforFilter(val, val1, val2)
{
	if(tree1.getLevel(val2)!=1 && tree1.getLevel(val2)!=6)
	{
		var level2=false;
		var level3=false;
		var level4=false;
		var level5=false;
		var level6=false;

		var addClass="";
		newRow = val1.insertRow(val1.rows.length);

		if(val1.rows.length%2 == 1)
		{
			addClass = "tblRow2";
		}
		else
		{
			addClass = "tblRow1";
		}

		treeText0 = val;
		treeID1 = tree1.getParentId(val2);
		treeText1 = tree1.getItemText(treeID1);
		treeID2 = tree1.getParentId(treeID1);
		treeText2 = tree1.getItemText(treeID2);
		treeID3 = tree1.getParentId(treeID2);
		treeText3 = tree1.getItemText(treeID3);
		treeID4 = tree1.getParentId(treeID3);
		treeText4 = tree1.getItemText(treeID4);
		if(tree1.getLevel(val2)==6)
		{
			var level2=true;
			var level3=true;
			var level4=true;
			var level5=true;
			var level6=true;

			var newTreeText0 = treeText4;
			var newTreeText1 = treeText3;
			var newTreeText2 = treeText2;
			var newTreeText3 = treeText1;
			var newTreeText4 = treeText0;
		}

		if(tree1.getLevel(val2)==5)
		{
			var level2=true;
			var level3=true;
			var level4=true;
			var level5=true;

			var newTreeText0 = treeText3;
			var newTreeText1 = treeText2;
			var newTreeText2 = treeText1;
			var newTreeText3 = treeText0;
		}

		if(tree1.getLevel(val2)==4)
		{
			var level2=true;
			var level3=true;
			var level4=true;

			var newTreeText0 = treeText2;
			var newTreeText1 = treeText1;
			var newTreeText2 = treeText0;
		}

		if(tree1.getLevel(val2)==3)
		{
			var level2=true;
			var level3=true;

			var newTreeText0 = treeText1;
			var newTreeText1 = treeText0;
		}

		if(tree1.getLevel(val2)==2)
		{
			var level2=true;

			var newTreeText0 = treeText0;
		}

		newCell1 = document.createElement("td");
		newCell1.setAttribute("className", addClass);
		newCell1.setAttribute("align", "center");
		newCell1.setAttribute("width", "3%");
		newCell1.innerHTML = '<a href="javascript:;" onclick="deleteDragTableRowforFilter(this,\''+val+'\', \''+val2+'\')"><img src="images/icon_deleteSmall.gif" alt="Delete" title="Delete" border="0" /></a><a href="javascript:;"></a>';

		newCell2 = document.createElement("td");
		newCell2.setAttribute("className", addClass);
		newCell2.setAttribute("width", "20%");
		if(level2)
		{
			newCell2.innerHTML = newTreeText0;
		}

		newCell3 = document.createElement("td");
		newCell3.setAttribute("className", addClass);
		newCell3.setAttribute("width", "18%");
		if(level3)
		{
			newCell3.innerHTML = newTreeText1;
		}

		newCell4 = document.createElement("td");
		newCell4.setAttribute("className", addClass);
		newCell4.setAttribute("width", "18%");
		if(level4)
		{
			newCell4.innerHTML = newTreeText2;
		}

		newCell5 = document.createElement("td");
		newCell5.setAttribute("className", addClass);
		newCell5.setAttribute("width", "18%");
		if(level5)
		{
			newCell5.innerHTML = newTreeText3;
		}

		newCell6 = document.createElement("td");
		newCell6.setAttribute("className", addClass);
		newCell6.setAttribute("width", "23%");
		if(level6)
		{
			newCell6.innerHTML = newTreeText4;
		}

		newRow.appendChild(newCell1);
		newRow.appendChild(newCell2);
		newRow.appendChild(newCell3);
		newRow.appendChild(newCell4);
		newRow.appendChild(newCell5);
		newRow.appendChild(newCell6);
	}
}

function getAllSelectedVals(val)
{
	selectedArray = "";
	Element.cleanWhitespace(document.getElementById(val));
	Element.cleanWhitespace(document.getElementById(val).childNodes[0]);
	Element.cleanWhitespace(document.getElementById(val).childNodes[0].childNodes[1]);
	tblObj = document.getElementById(val).childNodes[0].childNodes[1];
	for(i=0;i<tblObj.rows.length; i++)
	{
		if(tblObj.childNodes[i].id!=null)
		{
		var newSelId = tblObj.childNodes[i].id.split("#");

			if(newSelId[1])
			{
				if(selectedArray!="")
				{
					selectedArray = selectedArray + ", "+ newSelId[1];
				}
				else
				{
					selectedArray = selectedArray + newSelId[1];
				}
			}
			else
			{
				if(selectedArray!="")
				{
					selectedArray = selectedArray + ", "+ tblObj.childNodes[i].id;
				}
				else
				{
					selectedArray = selectedArray + tblObj.childNodes[i].id;
				}
			}
		}
	}
	return selectedArray;
}


function deleteDragTableRowforSecurityParent(val, val1)
{
	var totRows = 0;
	var idMatched = false;

	Element.cleanWhitespace(document.getElementById(val1));
	Element.cleanWhitespace(document.getElementById(val1).childNodes[0]);
	Element.cleanWhitespace(document.getElementById(val1).childNodes[0].childNodes[1]);
	var tblObj = document.getElementById(val1).childNodes[0].childNodes[1];
	for(i=0;i<tblObj.rows.length; i++)
	{
		if(tblObj.rows[i].id == val && !idMatched)
		{
			idMatched = true;
		}

		if(idMatched)
		{
			if(tblObj.childNodes[i].title=='')
			{
				totRows = totRows +1;
			}
			else
			{
				if(tblObj.childNodes[i].id!=val)
				{
					break;
				}
			}
		}
	}

	for(i=0;i<tblObj.rows.length; i++)
	{
		Element.cleanWhitespace(tblObj);
		if(tblObj.rows[i].id==val)
		{
			tblObj.deleteRow(tblObj.childNodes[i].rowIndex-1);
			for(j=0;j<totRows; j++)
			{
				tblObj.deleteRow(tblObj.childNodes[i].rowIndex -1);
			}
		}
	}
}

function deleteDragTableRowforSecurity(val)
{
	if(val.parentNode.parentNode.parentNode.rows.length>=2)
	{
		val.parentNode.parentNode.parentNode.deleteRow(val.parentNode.parentNode.rowIndex -1);
	}
}

function addDragTableRowforSecurityHead(val, val1, val2, val3)
{
	var addClass="";
	var headerFlag=0;
	var rowFlag=0;
	val2 = val2.split(",");
	var val1 = Element.cleanWhitespace(val1);
	for(z=0;z<val2.length; z++)
	{
		for(i=0;i<val1.childNodes[0].childNodes[1].rows.length; i++)
		{
			if(val1.childNodes[0].childNodes[1].childNodes[i].id == val2[z])
			{
				headerFlag = headerFlag + 1;
			}
		}
		if(headerFlag==0)
		{
			treeText = val;
			addClass = "tblRow3";
			newRowPN = val1.childNodes[0].insertRow(val1.childNodes[0].rows.length);
			newRowPN.setAttribute('id',val2[z]);
			newRowPN.setAttribute('title',treeText);

			newCellPN1 = document.createElement("td");
			if (BrowserDetect.browser=="Explorer")
				newCellPN1.setAttribute("className", addClass);
			else
			newCellPN1.setAttribute("class", addClass);
			newCellPN1.setAttribute("align", "center");
			newCellPN1.setAttribute("width", "3%");
			newCellPN1.innerHTML = '<a href="javascript:;" onclick="deleteDragTableRowforSecurityParent(\''+val2[z]+'\', \''+val1.id+'\')"><img src="images/icon_deleteSmall.gif" alt="Delete" title="Delete" border="0" /></a>';

			newCellPN2 = document.createElement("td");
				if (BrowserDetect.browser=="Explorer")
				newCellPN2.setAttribute("className", addClass);
			else
				newCellPN2.setAttribute("class", addClass);
			newCellPN2.setAttribute("width", "29%");
			newCellPN2.innerHTML = treeText;

			newCellPN3 = document.createElement("td");
			if (BrowserDetect.browser=="Explorer")
				newCellPN3.setAttribute("className", addClass);
			else
				newCellPN3.setAttribute("class", addClass);
			newCellPN3.setAttribute("width", "68%");

			newRowPN.appendChild(newCellPN1);
			newRowPN.appendChild(newCellPN2);
			newRowPN.appendChild(newCellPN3);
		}
		headerFlag=0;
	}
}

function addDragTableRowforSecurity(val, val1, val2, val3)
{
	var addClass="";
	var headerFlag=0;
	var rowFlag=0;
	var val1 = Element.cleanWhitespace(val1);

	val2 = val2.split(",");
	for(z=0;z<val2.length; z++)
	{
		if((val2[z].split("#")).length>1)
		{
			newSplitValue = val2[z].split("#")[1];
		}
		else
		{
			newSplitValue = val2[z];
		}

		treeText = val3.getItemText(val2[z]);
		treeParentID = val3.getParentId(val2[z]);
		treeParentIDText = val3.getItemText(treeParentID);
		//var outerVAL1 = getOuterHTML();
		//outerVAL1 = Element.cleanWhitespace(outerVAL1);

		Element.cleanWhitespace(val1.childNodes[0]);
		var headerObj=val1.childNodes[0].childNodes[1];

		for(i=0;i<headerObj.rows.length; i++)
		{
			if(headerObj.rows[i].id == val3.getParentId(val2[z]))
			{
				headerFlag = headerFlag + 1;
			}
		}

		if(headerFlag==0)
		{
			addClass = "tblRow3";
			newRowPN = val1.childNodes[0].insertRow(val1.childNodes[0].rows.length);
			newRowPN.setAttribute('id',treeParentID);
			newRowPN.setAttribute('title',treeParentIDText);
			newCellPN1 = document.createElement("td");
			if (BrowserDetect.browser=="Explorer")
				newCellPN1.setAttribute("className", addClass);
			else
				newCellPN1.setAttribute("class", addClass);

			newCellPN1.setAttribute("align", "center");
			newCellPN1.setAttribute("width", "3%");
			newCellPN1.innerHTML = '<a href="javascript:;" onclick="deleteDragTableRowforSecurityParent(\''+treeParentID+'\', \''+val1.id+'\')"><img src="images/icon_deleteSmall.gif" alt="Delete" title="Delete"  border="0" /></a><a href="javascript:;"></a>';
			newCellPN2 = document.createElement("td");
			if (BrowserDetect.browser=="Explorer")
				newCellPN2.setAttribute("className", addClass);
			else
				newCellPN2.setAttribute("class", addClass);
			newCellPN2.setAttribute("width", "29%");
			newCellPN2.innerHTML = treeParentIDText;
			newCellPN3 = document.createElement("td");
			if (BrowserDetect.browser=="Explorer")
				newCellPN3.setAttribute("className", addClass);
			else
				newCellPN3.setAttribute("class", addClass);
			newCellPN3.setAttribute("width", "68%");
			newRowPN.appendChild(newCellPN1);
			newRowPN.appendChild(newCellPN2);
			newRowPN.appendChild(newCellPN3);
		}
		headerFlag=0;

		dragJStartval= 0;
		Element.cleanWhitespace(val1.childNodes[0]);
		Element.cleanWhitespace(val1.childNodes[0].childNodes[1]);
		dragJEndval= val1.childNodes[0].childNodes[1].rows.length;
		var chkParentFlag = false;
		for(j=0;j<dragJEndval; j++)
		{
			if(treeParentID==val1.childNodes[0].childNodes[1].childNodes[j].id)
			{
				dragJStartval= j;
			}

			if(dragJStartval > 0)
			{
				if(val1.childNodes[0].childNodes[1].childNodes[j].id.indexOf('G_')>=0)
				{
					if(chkParentFlag){
						dragJEndval= j;
						break;
					}
					chkParentFlag = true;
				}
			}
		}
		for(i=dragJStartval;i<dragJEndval; i++)
		{
			if(val1.childNodes[0].childNodes[1].childNodes[i].id==newSplitValue)
			{
				rowFlag = rowFlag + 1;
			}
		}

		if(rowFlag==0)
		{
			Element.cleanWhitespace(val1.childNodes[0]);
			var tbodyObj=val1.childNodes[0].childNodes[1];
			for(i=0;i<tbodyObj.rows.length; i++)
			{
				if(tbodyObj.rows[i].id == val3.getParentId(val2[z]))
				{
					if(val1.childNodes[0].rows.length%2 == 1)
						addClass = "tblRow2";
					else
						addClass = "tblRow1";
					Element.cleanWhitespace(tbodyObj.childNodes[i]);

					newRowIndex = tbodyObj.rows[i].rowIndex +1;

					newRow = val1.childNodes[0].insertRow(newRowIndex);
					treeText3 = newSplitValue;
					if(val2[z].indexOf("_") >= 0)
					{
						treeText3 = treeText3.substr(0,treeText3.lastIndexOf("_"));
					}
					newRow.setAttribute('id',treeText3);

					newCell1 = document.createElement("td");
					if (BrowserDetect.browser=="Explorer")
						newCell1.setAttribute("className", addClass);
					else
						newCell1.setAttribute("class", addClass);
					newCell1.setAttribute("align", "center");
					newCell1.setAttribute("width", "3%");
					newCell1.innerHTML = '<a href="javascript:;" onclick="deleteDragTableRowforSecurity(this,\''+val+'\', \''+newSplitValue+'\')"><img src="images/icon_deleteSmall.gif" alt="Delete" title="Delete" border="0" /></a><a href="javascript:;"></a>';

					newCell2 = document.createElement("td");
					if (BrowserDetect.browser=="Explorer")
						newCell2.setAttribute("className", addClass);
					else
						newCell2.setAttribute("class", addClass);
					newCell2.setAttribute("width", "29%");
					//newCell2.innerHTML = treeParentIDText;

					newCell3 = document.createElement("td");
					if (BrowserDetect.browser=="Explorer")
						newCell3.setAttribute("className", addClass);
					else
						newCell3.setAttribute("class", addClass);
					newCell3.setAttribute("width", "68%");
					newCell3.innerHTML = treeText;

					newRow.appendChild(newCell1);
					newRow.appendChild(newCell2);
					newRow.appendChild(newCell3);
				}
			}
		}
		rowFlag=0;
	}

	if (document.all)
	document.onselectstart =
	function () { return true; };
}
function selectDrillDownImages(val)
{
	document.getElementById(val).src= 'images/icon_analysis_drillDownSel.gif';
}
function selectDrillAccImages(val)
{
	document.getElementById(val).src= 'images/icon_analysis_drillAccrossSel.gif';
}
function addIcontoShowInvisible(val)
{
	innerImages = document.getElementById(val.value).getElementsByTagName("img");
	if(val.checked)
	{
		innerImages[0].style.display="none";
	}
	else
	{
		innerImages[0].style.display="inline";
	}
}
function addIcontoShowTotal(val)
{
	innerImages = document.getElementById(val.value).getElementsByTagName("img");


	if(val.checked)
	{
		innerImages[1].style.display="none";
	}
	else
	{
		innerImages[1].style.display="inline";
	}
}
/*Cross Tab / Graph pub ENDS*/

function showHideControl(id1, id2){
document.getElementById(id1).style.display='inline';
document.getElementById(id2).style.display='none';
}
function setSelectedValueForLink(id1, id2)
{
	id2 = eval('document.form1.'+id2);
	for(var i=0 ;i < id2.length;i++)
	{
		if(id2.options[i].selected == true)
		{
			document.getElementById(id1).innerHTML = id2.options[i].text;
		}
	}
}

function setSelectedValueForLinkInput(id1, id2){
      document.getElementById(id1).innerHTML = eval("document.form1."+id2).value;
      val = (eval("document.form1."+id2).value).split(",");
      val1='';
      for(i=0; i<=val.length-1; i++)
      {
            if(val1=='')
            {val1 = val[i];}
            else
            {val1 = val1 + "\n" + val[i];}
      }
      document.getElementById(id1).title = val1;
}

function showHideCalendar(){

	var obj=document.getElementById("dhtmlxDblCalendar");
	if(obj.style.display=="none")
		obj.style.display="inline";
	else
		obj.style.display="none";
}

var newKPIMenu = "";
var oldKPIMenu = "";
var KPIMenuFlag = true;
var insertFlag = false;
var startFlag = false;
var endFlag = false;
var existsFlag = false;
var menuInc=0;
var kpiInc=0;

function searchKPIs(val, val1, val2)
{
val1.value = stripCharacter(val1.value,"*");
val1.value = stripCharacter(val1.value,"\\");
	slash_expandall();
	newKPIMenu = "";
	insertFlag = false;

	if(KPIMenuFlag)
	{
		document.getElementById(val2).innerHTML = document.getElementById(val).innerHTML;
		oldKPIMenu = document.getElementById(val).innerHTML;
		KPIMenuFlag=false;
	}
	else
	{
		document.getElementById(val2).innerHTML = oldKPIMenu;
	}

	obj = document.getElementById(val2).getElementsByTagName("div");

	if(val1.value=="")
	{
		document.getElementById(val).innerHTML= oldKPIMenu;
		document.getElementById(val2).innerHTML="";
		init();
		slash_expandall();
	}
	else
	{
		for(i=0; i<=obj.length-1; i++)
		{
			if(obj[i].innerHTML!=null)
			{
				innerString = obj[i].innerHTML.toLowerCase();
				if(innerString.search(val1.value.toLowerCase())!=-1)
				{

					for(k=0; k<=obj[i].childNodes.length-1; k++)
					{
						if(obj[i].childNodes[k].innerHTML!=null)
						{
							innerString = obj[i].childNodes[k].innerHTML.toLowerCase();
							if(innerString.search(val1.value.toLowerCase())!=-1)
							{
								existsFlag=true;
							}
						}
					}

					if(existsFlag)
					{
						if(obj[i].className!='title' && obj[i].className!='truncateText')
						{

							menuInc = menuInc + 1;
							kpiInc = 0;
							obj[i].previousSibling.id = menuInc;
							//Firefox fix for Search KPIs - outerHTML
							newKPIMenu = newKPIMenu + getOuterHTML(obj[i].previousSibling);
							newKPIMenu = newKPIMenu + '<div class="submenu">';
							startFlag = true;
							existsFlag = false;
						}
					}
				}
			}
			for(j=0; j<=obj[i].childNodes.length-1; j++)
			{
				if(obj[i].childNodes[j].innerHTML!=null)
				{
					innerString = obj[i].childNodes[j].innerHTML.toLowerCase();
					if(innerString.search(val1.value.toLowerCase())!=-1)
					{
						kpiInc = kpiInc + 1;
						kpiIncNew = menuInc+"_"+ kpiInc;
						obj[i].childNodes[j].id = kpiIncNew;
						//Firefox fix for Search KPIs - outerHTML
						newKPIMenu = newKPIMenu + getOuterHTML(obj[i].childNodes[j]);
						insertFlag = true;
					}
				}

				if((j+1)==obj[i].childNodes.length)
				{
					if(startFlag)
					{
						endFlag = true;
						startFlag = false;
					}
				}
			}

			if(endFlag)
			{
				newKPIMenu = newKPIMenu + '</div>';
				endFlag = false;
			}
		}

		if(insertFlag)
		{
			document.getElementById(val).innerHTML= newKPIMenu;
			document.getElementById(val2).innerHTML = "";
			init();
			kpiInc=0;
			menuInc=0;
			//slash_contractall();
			//showmenu('0');
			slash_expandall();
			document.getElementById('searchString').focus();
			document.getElementById('searchString').select();
		}
		else
		{
			document.getElementById('searchString').value = generalMsg[69];
			document.getElementById('searchString').focus();
			document.getElementById('searchString').select();
		}
	}
}
/*BEGIN Form level validation - ruben*/

function validateNSubmit(val, val1)
{
	var errCodeNull="";
	var errCodeNum="";
	var errCodeSchar="";
	var errCodePass="";
	var errCodeEmail="";
	var errCodeCombo="";
	var totalErr="";

	valResult="";
	passCheck="";
	passCheckArray="";
	allFields = val.split("; ");
	for(i=0; i<=allFields.length-1; i++)
	{
		thisFieldArray = allFields[i].split(":");

		thisField = thisFieldArray[0];
		thisFieldOpe = thisFieldArray[1].split(",")

		var valResult = valResult + eval("toValidate('"+thisField+"', '"+thisFieldOpe+"')");
	}

	valResult = valResult.split(", ");
	for(k=0; k<=valResult.length-2; k++)
	{
		errorFieldsArray = valResult[k].split(":");

		errorField = errorFieldsArray[0];
		errorFieldIssue = errorFieldsArray[1];

		if(errorFieldIssue=="null")
		{
			document.getElementById(errorField).className = "inputFieldErr";
			errCodeNull = "null";
		}

		if(errorFieldIssue=="number")
		{
			document.getElementById(errorField).className = "inputFieldErr";
			errCodeNum = "number";
		}

		if(errorFieldIssue=="sChar")
		{
			document.getElementById(errorField).className = "inputFieldErr";
			errCodeSchar = "sChar";
		}

		if(errorFieldIssue=="pass")
		{
			document.getElementById(errorField).className = "inputFieldErr";
			document.getElementById('confirmPassword').className = "inputFieldErr";
			errCodePass =  "pass";
		}

		if(errorFieldIssue=="email")
		{
			document.getElementById(errorField).className = "inputFieldErr";
			errCodeEmail =  "email";
		}

		if(errorFieldIssue=="combo")
		{
			document.getElementById(errorField).className = "inputFieldErrSel";
			errCodeCombo =  "combo";
		}
	}
	if(errCodeNull == "null")
	{
		totalErr = totalErr + '<span class="contentRed">'+generalMsg[58] +'</span>';
	}

	if(errCodeNum == "number")
	{
		totalErr = totalErr + '<span class="contentRed">'+generalMsg[59] +' </span>';
	}

	if(errCodeSchar == "sChar")
	{
		totalErr = totalErr + '<span class="contentRed">'+generalMsg[60] +'</span>';
	}

	if(errCodePass == "pass")
	{
		totalErr = totalErr + '<span class="contentRed">'+generalMsg[61] +'</span>';
	}

	if(errCodeEmail == "email")
	{
		totalErr = totalErr + '<span class="contentRed">'+generalMsg[62] +' </span>';
	}

	if(errCodeCombo == "combo")
	{
		totalErr = totalErr + '<span class="contentRed">'+generalMsg[63] +' </span>';
	}

	if(totalErr!="")
	{
		if(parent.document.getElementById('mandatorySection'))
		{
			parent.document.getElementById('mandatorySection').innerHTML = totalErr;
		}
		if(parent.document.getElementById('mandatorySection1'))
		{
			parent.document.getElementById('mandatorySection1').innerHTML = totalErr;
		}
	}
	else
	{
		if(parent.document.getElementById('mandatorySection'))
		{
			parent.document.getElementById('mandatorySection').innerHTML= '<span class="contentGreen">'+val1+'</span>';
		}
		if(parent.document.getElementById('mandatorySection1'))
		{
			parent.document.getElementById('mandatorySection1').innerHTML= '<span class="contentGreen">'+val1+'</span>';
		}
		return true;
	}
}

function toValidate(val, val1)
{
	whiteSpace = new RegExp(/^\s+$/);

	document.getElementById(val).className = "inputField";

	returnFlag="";

	thisFieldOpes = val1.split(",");

	for(j=0; j<=thisFieldOpes.length-1; j++)
	{
		if(thisFieldOpes[j]=='nn')
		{
			if(trim(document.getElementById(val).value)=="" || whiteSpace.test(trim(document.getElementById(val).value)))
			{
				returnFlag =returnFlag + (val + ":null, ");
			}
		}

		if(thisFieldOpes[j]=='num')
		{
			var numChar="0123456789";
			var data= trim(document.getElementById(val).value);
			for (var i = 0; i < data.length; i++)
			{
			  	if (numChar.indexOf(data.charAt(i)) != -1)
			  	{
			  	  returnFlag =returnFlag + (val + ":number, ");
			  	}
			  	break;
			}
		}

		if(thisFieldOpes[j]=='sc')
		{
			var specialChar="!@#$%^&*()+=[]\\\';,/{}|\":<>?~";
			var data= trim(document.getElementById(val).value);
			for (var i = 0; i < data.length; i++)
			{
			  	if (specialChar.indexOf(data.charAt(i)) != -1)
			  	{
			  	  returnFlag =returnFlag + (val + ":sChar, ");
			  	}
			}
		}
		//Restricted Special Characters
		if(thisFieldOpes[j]=='rsc')
		{
			var specialChar="!@#$^&*+=\\\';,|\":<>?~";
			var data= trim(document.getElementById(val).value);
			for (var i = 0; i < data.length; i++)
			{
			  	if (specialChar.indexOf(data.charAt(i)) != -1)
			  	{
			  	  returnFlag =returnFlag + (val + ":sChar, ");
			  	}
			}
		}
		if(thisFieldOpes[j]=='cp')
		{
			if(trim(document.getElementById(val).value) != document.getElementById('confirmPassword').value)
			{
				returnFlag = returnFlag + (val + ":pass, ");
			}
		}

		if(thisFieldOpes[j]=='e')
		{
			var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
			if (!filter.test(trim(document.getElementById(val).value)))
			{
				returnFlag = returnFlag + (val + ":email, ");
			}
		}

		if(thisFieldOpes[j]=='sl')
		{
			if (document.getElementById(val).length==0)
			{
				returnFlag = returnFlag + (val + ":combo, ");
			}
		}
	}
	return returnFlag;
}

function passMatch(passCheck)
{
	if(passCheck!="")
	{
		passCheckArray = passCheck.split(",");

		if(passCheckArray.length>=3)
		{
			if(passCheckArray[0] != passCheckArray[1])
			{
				returnFlag = val + ":pass, ";
			}
		}
	}
}
/*END Form level validation - ruben*/
/*ListBox Select -ruben*/
function addVal(from,to)
{
	fromList = document.getElementById(from);
	toList = document.getElementById(to);
	if (toList.options.length > 0 && toList.options[0].value == 'temp')
	{
		toList.options.length = 0;
	}
	for (i=0;i<fromList.options.length;i++)
	{
		var current = fromList.options[i];
		if (current.selected)
		{
			txt = current.text;
			val = current.value;
			toList.options[toList.length] = new Option(txt,val);
		}
	}
	for (k=0;k<toList.options.length;k++)
	{
		for (j=0;j<fromList.options.length;j++)
		{
			if (fromList.options[j].value==toList.options[k].value)
			{
				fromList.remove(j);
			}
		}
	}
	fromList.selectedIndex='-1';
}
function addAllVal(from,to)
{
	fromList = document.getElementById(from);
	toList = document.getElementById(to);
	if (toList.options.length > 0 && toList.options[0].value == 'temp')
	{
		toList.options.length = 0;
	}
	for (i=0;i<fromList.options.length;i++)
	{
		var current = fromList.options[i];
		txt = current.text;
		val = current.value;
		toList.options[toList.length] = new Option(txt,val);
	}
	for (j=0;j<fromList.options.length;j++)
	{
		for (k=0;k<toList.options.length;k++)
			{
				if (fromList.options[j].value==toList.options[k].value)
				{
					fromList.remove(j);
				}
			}
	}
	fromList.selectedIndex='-1';
}
/*ListBox Select Ends -ruben*/
/*My Dashboard Menu - submenu views the respective user layout - Sanjay Dtd. 08th April 2008*/
function displayDashboard(layoutId,ownerId,viewName){
	moduleClick('home','9_module','1','moduleClick');
	document.getElementById('datamain').src="/c/portal/layout?p_l_id="+ownerId+"."+layoutId;
	document.getElementById('myDashboard').style.display='none';
}

/*My Dashboard Menu - Ends Here */
//Rasmit
//start:chitta
//Numeric validation for keypress event
function maskNumeric(evt)
{
var charCode = (evt.which) ? evt.which : event.keyCode
if ((charCode < 48 || charCode > 57) )
return false;
return true;
}
//end:chitta

var putHour = "";
var putMin = "";
var chkAfterETL = false;
var maintainFlag = false;

function afterETL(chk){
document.getElementById("exetime").value = '0' ;
	chkAfterETL = true;
	if(chk.checked){
	if(!maintainFlag) {
		putHour = document.getElementById("startHours").value;
		putMin = document.getElementById("startMins").value;
     }
        if(document.getElementById("schedNow").checked || document.getElementById("onetimeSchedule").checked ) {
	        document.getElementById("monthlySchedule").checked=true;
	        document.getElementById("schedNow").checked=false;
	        document.getElementById("onetimeSchedule").checked=false;
	        showRecurr('daily');
        }

		document.getElementById("startHours").value="00";
		document.getElementById("startMins").value="00";
		document.getElementById("startHours").disabled = true;
		document.getElementById("startMins").disabled = true;
		document.getElementById("schedNow").disabled = true;
		document.getElementById("onetimeSchedule").disabled = true;

	} else if(!chk.checked) {
		document.getElementById("startHours").value=putHour;
		document.getElementById("startMins").value=putMin;
		document.getElementById("startHours").disabled = false;
		document.getElementById("startMins").disabled = false;
		document.getElementById("schedNow").disabled = false;
		document.getElementById("onetimeSchedule").disabled = false;
	}
}
//exetime
function disableTime(flag){
	if(!chkAfterETL){
		putHour = document.getElementById("startHours").value;
		putMin = document.getElementById("startMins").value;
	}
	maintainFlag = flag;
	if(flag) {
	if(document.addAlertFrm.etlChk.checked) {
			putHour = document.getElementById("startHours").value;
			putMin = document.getElementById("startMins").value;
	 }
			document.getElementById("startHours").value="";
			document.getElementById("startMins").value="";
			document.getElementById("startHours").disabled = true;
			document.getElementById("startMins").disabled = true;
	} else {
			if(!document.addAlertFrm.etlChk.checked) {

				document.getElementById("startHours").value=putHour;
				document.getElementById("startMins").value=putMin;
				document.getElementById("startHours").disabled = false;
				document.getElementById("startMins").disabled = false;
			}
	}
}

function echeck(str) {
	var emailRegxp1 =/^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/;
	var to_array =new Array();
	if(str.indexOf(",")!=-1){
		 to_array = str.split(",");
	}else{
		to_array[0] = str;
	}
	if(to_array.length!=0)
	for (var i = 0; i < to_array.length; i++)
	{

	    var trimmedValue = trim(to_array[i]);
		if(trimmedValue!=undefined && trimmedValue!=null && trimmedValue!=""){
			if (emailRegxp1.test(trimmedValue) != true)// && emailRegxp2.test(trimmedValue) == true)
			{
				if(!trimmedValue.match(/^[@]/)){
					if(parent.document.getElementById('mandatorySection')){
						parent.document.getElementById('mandatorySection').innerHTML ="";
						parent.document.getElementById('mandatorySection').innerHTML ="<font style='color:red;'>Please enter a valid E-mail ID.</font>";
					}
					return false;
				}
			}
		}
	}
		 return true;
}

function ValidateFormEmail(){
	var emailID=document.addAlertFrm.recipientsEmail.value;
	var arr = new Array;
	if(emailID.indexOf(",")==-1) {
			arr = emailID.split(",");
		} else {
			arr = emailID;
		}
	if(arr.length==0){
		popupTabber.setTabActive('recipients');
		setValidationMessage(generalMsg[8]);
		return false;
	}
	for(i=0;i<arr.length;i++) {
		if(arr[i]==undefined && arr.length!=0){
			if (!echeck(document.addAlertFrm.recipientsEmail.value)){
				popupTabber.setTabActive('recipients');
				document.addAlertFrm.recipientsEmail.focus();
				document.addAlertFrm.recipientsEmail.select();
				return false
			}
		}
		if(arr[i]!=undefined){
			if ((arr[i]==null)||(arr[i]=="")){
				popupTabber.setTabActive('recipients');
				setValidationMessage(generalMsg[8]);
				document.addAlertFrm.recipientsEmail.focus();
				document.addAlertFrm.recipientsEmail.select();
				return false
			}
			if (!echeck(arr[i])){
				popupTabber.setTabActive('recipients');
				arr[i]="";
				document.addAlertFrm.recipientsEmail.focus();
				document.addAlertFrm.recipientsEmail.select();
				return false
			}
		}
	}
	return true
 }

function saveTemplates(){
	if(popUpFrame.form1.isModify.value == 'yes'){
		 var success = modifyTemplates();
		 if ( success == 'true'){
		 	return ;
		 }
	}
	addMeasureExpressions( popUpFrame.form1.measureIds.value , popUpFrame.form1.expressionIds.value );
	 var templateName = popUpFrame.form1.templateName.value;
	 var expr = popUpFrame.form1.expressionIds.value;
	expr = expr.replace('&&','#');
		if ( templateName == "" || templateName == null ){
				setValidationMessage( generalMsg[9] );
			return ;
		}
		else if ( expr == "" || expr == null){
				setValidationMessage( generalMsg[10]);
			return ;
		}
		else{
				var params = Form.serialize(document.getElementById(popUpFrame.form1));
				var URL="alertnew?addTemplates=yes&templateName="+templateName+"&exp="+expr;
				new Ajax.Updater({success: 'mandatorySection'}, URL, {asynchronous:true,parameters: params, onFailure: reportError, evalScripts: true});
		}
}

function modifyTemplates(){
	var isSuccess = "true" ;
	addMeasureExpressions( popUpFrame.form1.measureIds.value , popUpFrame.form1.expressionIds.value );
	 var templateName = popUpFrame.form1.templateName.value;
	 var expr = popUpFrame.form1.expressionIds.value;
		expr = expr.replace('&&','#');
		if ( templateName == "" || templateName == null ){
				setValidationMessage(generalMsg[9]);
			return ;

		}
		else if ( expr == "" || expr == null){
				setValidationMessage(generalMsg[10]);
			return ;
		}
		else{
				var con = confirm(generalMsg[11]);
				if ( con ){
					var params = Form.serialize(document.getElementById(popUpFrame.form1));
					var URL="alertnew?modifyToDB=yes&expressionModify="+expr+"&templateName="+templateName;
					new Ajax.Updater({success: 'mandatorySection'}, URL, {asynchronous:true,parameters: params, onFailure: reportError, evalScripts: true});
				}
				else{

					// return to the same page
				}
		}
		return isSuccess;
}

function getExpressions(){
	var templateName = '';
	if(document.getElementById('template')){
		templateName = document.getElementById('template').options[document.getElementById('template').selectedIndex].text;
	}
	var expressionMeasures = '';
	if(document.getElementById('expressionMeasures')){
		expressionMeasures = document.getElementById('expressionMeasures').value;
	}
	var URL="alertnew?showExpressions=yes&tempName="+templateName+"&expressionMeasures="+encodeURIComponent(expressionMeasures) ;
	new Ajax.Request(URL, {asynchronous:true, onFailure: reportError, evalScripts: true,onComplete:setRuleFortheExpr});
	document.getElementById('showExpressions').innerHTML="&nbsp;" ;
}

function setRuleFortheExpr(resObj){
	var temp = resObj.responseText;
	document.getElementById('showExpressions').innerHTML=temp.split("</script>")[1];
	var str = temp.split("</script>")[0].split("<script>")[1];
	eval(str);
}

function getRuleForExpr(val, val1 , expressions){
	if(val1 != null && val1.checked){
		document.getElementById("ruleBuilder").style.display='block';
	}
	if(val1 == null || !val1.checked){
		document.getElementById("ruleBuilder").style.display='none';
	}

	var pos = '';

	if ( expressions.indexOf('&&') != -1  ){
		pos=expressions.indexOf('&&');
	}

	if ( expressions.indexOf('||') != -1  ){
		pos=expressions.indexOf('||');
	}

	if ( expressions.indexOf('(') != -1  ){
		pos=expressions.indexOf('(');
	}

	if ( expressions.indexOf(')') != -1  ){
		pos=expressions.indexOf(')');
	}

	if ( expressions.indexOf('!=') != -1  ){
		pos=expressions.indexOf('!=');
	}

	if ( expressions.indexOf('==') != -1  ){
		pos=expressions.indexOf('==');
	}

	if ( expressions.indexOf('<') != -1  ){
		pos=expressions.indexOf('<');
	}

	if ( expressions.indexOf('>') != -1  ){
		pos=expressions.indexOf('>');
	}

	if ( expressions.indexOf('+') != -1  ){
		pos=expressions.indexOf('+');
		//return pos ;
	}

	if ( expressions.indexOf('-') != -1  ){
		pos=expressions.indexOf('-');
	}

	if ( expressions.indexOf('*') != -1  ){
		pos=expressions.indexOf('*');
	}

	if ( expressions.indexOf('/') != -1  ){
		pos=expressions.indexOf('/');
	}

	var expr = expressions.substring(0,pos+1);
	document.addAlertFrm.leftExpr.value = expr ;
	var expval = expressions.substring(pos+1,expressions.length);
	document.addAlertFrm.rightExpr.value = expval ;

	var URL="alertnew?ruleBuilder=yes&expression="+encodeURIComponent(expr)+"&expval="+encodeURIComponent(expval);
	new Ajax.Updater({success: 'ruleBuilder'}, URL, {asynchronous:true, onFailure: reportError, evalScripts: true});
}

function reportError(){
	alert(generalMsg[12]);
}

function getDateObject(dateString,dateSeperator)
{
	//This function return a date object after accepting
	//a date string ans dateseparator as arguments
	var curValue=dateString;
	var sepChar=dateSeperator;
	var curPos=0;
	var cDate,cMonth,cYear;

	//extract day portion
	curPos=dateString.indexOf(sepChar);
	cDate=dateString.substring(0,curPos);

	//extract month portion
	endPos=dateString.indexOf(sepChar,curPos+1);
	cMonth=dateString.substring(curPos+1,endPos);

	//extract year portion
	curPos=endPos;
	endPos=curPos+5;
	cYear=curValue.substring(curPos+1,endPos);

	//Create Date Object
	dtObject=new Date(cYear,cMonth,cDate);
	return dtObject;
}


function formatDate(date,format) {
	format=format+"";
	var result="";
	var i_format=0;
	var c="";
	var token="";
	var y=date.getYear()+"";
	var M=date.getMonth()+1;
	var d=date.getDate();
	var E=date.getDay();
	var H=date.getHours();
	var m=date.getMinutes();
	var s=date.getSeconds();
	var yyyy,yy,MMM,MM,dd,hh,h,mm,ss,ampm,HH,H,KK,K,kk,k;
	// Convert real date parts into formatted versions
	var value=new Object();
	if (y.length < 4) {y=""+(y-0+1900);}
	value["y"]=""+y;
	value["yyyy"]=y;
	value["yy"]=y.substring(2,4);
	value["M"]=M;
	value["MM"]=LZ(M);
	value["MMM"]=MONTH_NAMES[M-1];
	value["NNN"]=MONTH_NAMES[M+11];
	value["d"]=d;
	value["dd"]=LZ(d);
	value["E"]=DAY_NAMES[E+7];
	value["EE"]=DAY_NAMES[E];
	value["H"]=H;
	value["HH"]=LZ(H);
	if (H==0){value["h"]=12;}
	else if (H>12){value["h"]=H-12;}
	else {value["h"]=H;}
	value["hh"]=LZ(value["h"]);
	if (H>11){value["K"]=H-12;} else {value["K"]=H;}
	value["k"]=H+1;
	value["KK"]=LZ(value["K"]);
	value["kk"]=LZ(value["k"]);
	if (H > 11) { value["a"]="PM"; }
	else { value["a"]="AM"; }
	value["m"]=m;
	value["mm"]=LZ(m);
	value["s"]=s;
	value["ss"]=LZ(s);
	while (i_format < format.length) {
		c=format.charAt(i_format);
		token="";
		while ((format.charAt(i_format)==c) && (i_format < format.length)) {
			token += format.charAt(i_format++);
			}
		if (value[token] != null) { result=result + value[token]; }
		else { result=result + token; }
		}
	return result;
	}

// Rasmit
String.prototype.trim = function() {

	return this.replace(/^\s+|\s+$/g,"");
}
String.prototype.ltrim = function() {
	return this.replace(/^\s+/,"");
}
String.prototype.rtrim = function() {
	return this.replace(/\s+$/,"");
}
// Rasmit added
// used to set the default style class of all the TextBoxes, CheckBoxes, ComboBoxes in the form
function resetTextBoxClassDefault(frmObj)
{
	for(i=0;i < frmObj.elements.length;i++)
	{
		if(frmObj.elements[i].type=="text"){
			if(frmObj.elements[i].className=="inputFieldErr"){
				frmObj.elements[i].className="inputField";
			}
		}
		if(frmObj.elements[i].type=="checkbox"){
			if(frmObj.elements[i].className=="inputFieldErrCheck"){
				frmObj.elements[i].className="";
			}
		}
		if(frmObj.elements[i].type=="select-one"){
			if(frmObj.elements[i].className=="inputFieldErrSel"){
				frmObj.elements[i].className="inputField";
			}
		}
		if(frmObj.elements[i].type=="select-multiple"){
			if(frmObj.elements[i].className=="inputFieldErrSel"){
				frmObj.elements[i].className="inputField";
			}
		}
		if(frmObj.elements[i].type=="textarea"){
			if(frmObj.elements[i].className=="inputFieldErr"){
				frmObj.elements[i].className="inputField";
			}
		}
		if(frmObj.elements[i].type=="file"){
			if(frmObj.elements[i].className=="inputFieldErr"){
				frmObj.elements[i].className="inputField";
			}
		}
		// Added by Rasmit
		if(frmObj.elements[i].type=="radio"){
			if(frmObj.elements[i].className=="inputFieldErrCheck"){
				frmObj.elements[i].className="";
			}
		}
	}
}
function resetFormElements(form){
	parent.$('mandatorySection').innerHTML= generalMsg[73];
	resetTextBoxClassDefault(form);
}

function specialCharChk(name,id,formName){
		var specialChar="!^*()&+=-[]\\\';,./{}|\":<>?~";
		var data= name;
		for (var i = 0; i < data.length; i++)
		{
		  	if (specialChar.indexOf(data.charAt(i)) != -1)
		  	{
		  		if(document.getElementById(id))
		  	   		document.getElementById(id).className = "inputFieldErr";
		  	   	else
		  	   		formName.id.className = "inputFieldErr";
			 //  alert('Please Give a Name Without Selecting Any Special Characters.');
			   setValidationMessage(generalMsg[13]);
			   return true;
		  	}
		}
		var numericChar="1234567890";
		var data2= name;

	  	if (numericChar.indexOf(data2.charAt(0)) != -1)
	  	{
	  		if(document.getElementById(id))
	  	  		 document.getElementById(id).className = "inputFieldErr";
	  	  	 else
	  	  		 formName.id.className = "inputFieldErr";

		   setValidationMessage(generalMsg[14]);
		   return true;
	  	}

		return false;
	}
function validateAll()
{
	// resets the style class of all the elements of the form
  	resetTextBoxClassDefault(document.addAlertFrm);
	var isValid = true ;
	var counter = 0 ;
	var alertName = document.addAlertFrm.alertNameTxt.value ;

	// Alert name validation
	if (alertName == "" || alertName == null )
	{
		setValidationMessage(generalMsg[15]);
		popupTabber.setTabActive('general');
		document.addAlertFrm.alertNameTxt.className="inputFieldErr";
		isValid = false ;
		return isValid ;
	}
	if(specialCharChk(alertName,"alertNameTxt",document.addAlertFrm))return;
	// Tempalate validation
	if(document.getElementById('template') && document.addAlertFrm.template.value == 'select')
	{
		setValidationMessage(generalMsg[16]);
		popupTabber.setTabActive('general');
		isValid = false ;
		return isValid;
	}
	// Expression Validation
	if(document.getElementById('chkBx')!=null && !document.getElementById('chkBx').checked)
	{
		setValidationMessage(generalMsg[17]);
		popupTabber.setTabActive('general');
		isValid = false;
		return isValid;
	}
	// Rule textbox validation
	if(document.addAlertFrm.text1 != null)
	{
		if(document.addAlertFrm.text1.length == 'undefined' || document.addAlertFrm.text1.length == undefined )
		{
			if (isNaN(parseInt(document.addAlertFrm.text1.value)))
			{
				setValidationMessage(generalMsg[18]);
				popupTabber.setTabActive('general');
				document.addAlertFrm.text1.focus();
				isValid = false ;
				return isValid;
			}
		}
	}
	// Scheduling validation starts here
	var startHrs = document.addAlertFrm.startHours.value ;
	var startMins = document.addAlertFrm.startMins.value ;
	var selectedSchedule = '' ;
	for( var i = 0 ; i < document.addAlertFrm.recurrence.length ; i++)
	{
		if(document.addAlertFrm.recurrence[i].checked == true )
		{
			selectedSchedule = document.addAlertFrm.recurrence[i].value ;
		}
	}
	var afterETLObj = document.getElementById('etlChk');
	if(selectedSchedule.trim() != 'schedulenow' && !afterETLObj.checked)
	{
		if(selectedSchedule.trim() != 'schedNow')
		{
			if( startHrs == null || startHrs == "" || startMins == null || startMins == "" || isNaN(startHrs)==true || isNaN(startMins) == true )
			{
				setValidationMessage (generalMsg[19]);
				popupTabber.setTabActive('Schedule');
				document.addAlertFrm.startHours.className = "inputFieldErr";
				document.addAlertFrm.startMins.className = "inputFieldErr";
				isValid =  false ;
				return isValid ;
			}
			var hrs = document.addAlertFrm.startHours.value ;
			var mins = document.addAlertFrm.startMins.value;
			var currDate = currDateObj;
			var enteredHrs = hrs;
			var count =0;
			for( var hourss = 0; hourss < enteredHrs.length; hourss++ )
			{
				count++;
			}
			if(count>=3)
			{
				popupTabber.setTabActive('Schedule');
				document.addAlertFrm.startHours.className = "inputFieldErr";
				setValidationMessage(generalMsg[20]);
				return false;
			}
			// Issue Fix: 6539 ---shiva
			enteredHrs = parseInt(enteredHrs,10);
			var currHrs = currDate.getHours();
			var enteredMins = parseInt( mins,10);
			//end----shiva
			var count2 =0;
			for( var MINS = 0; MINS < enteredMins.length; MINS++ )
			{
				count2++;
			}
			if(count2>=3)
			{
				popupTabber.setTabActive('Schedule');
				document.addAlertFrm.startMins.className = "inputFieldErr";
				setValidationMessage(generalMsg[21]);
				return false;
			}
		}
	}
	var daily = document.addAlertFrm.daily ;
	var days = document.addAlertFrm.ddays.value ;
	if(selectedSchedule == "onetimeSchedule" && !afterETLObj.checked)
	{
		var oneTimeDate = document.addAlertFrm.oneTstartdate.value ;
		var isTimeValid = false;
		var hrs = document.addAlertFrm.startHours.value ;
		var mins = document.addAlertFrm.startMins.value ;
		var startdate = document.addAlertFrm.oneTstartdate.value;
		var enteredDate = startdate;
		var currDate = currDateObj;
		var enteredHrs = hrs;
		enteredHrs = parseInt(enteredHrs,10);
		var currHrs = currDate.getHours();
		var enteredMins = mins;
		enteredMins = parseInt(enteredMins,10);
		var currMins = currDate.getMinutes();
		var cMon = currDate.getMonth()+1;

		if(parseInt(hrs)>24 && parseInt(mins)>60)
		{
			setValidationMessage(generalMsg[22]);
			popupTabber.setTabActive('Schedule');
			document.addAlertFrm.startHours.className = "inputFieldErr";
			document.addAlertFrm.startMins.className = "inputFieldErr";
			isValid =  false;
			return isValid ;
		}
		if(oneTimeDate == "" || oneTimeDate == null )
		{
			setValidationMessage(generalMsg[23]);
			popupTabber.setTabActive('Schedule');
			document.addAlertFrm.oneTstartdate.className = "inputFieldErr";
			isValid =  false;
			return isValid ;
		}
		isValid = validateHrs(document.addAlertFrm.startHours);
		if(isValid)
		{
			isValid = validateMins(document.addAlertFrm.startMins);
			if(isValid)
			{
				if(cMon<=9)
				{
					cMon = "0"+cMon ;
				}
				var cDay = currDate.getDate();
				if(cDay<=9)
				{
					cDay = "0"+cDay ;
				}
				var currDateInString = new Date(currDate.getFullYear(),currDate.getMonth(),currDate.getDate());
				var splitString = enteredDate.split("-");
				var enteredDateTemp = new Date(splitString[0],""+((splitString[1])-1),splitString[2]);
				if(enteredDateTemp.getFullYear() == currDateInString.getFullYear() &&
					enteredDateTemp.getMonth() == currDateInString.getMonth() &&
						enteredDateTemp.getDate() == currDateInString.getDate())
				{
					if((enteredHrs < currHrs) || (enteredHrs == currHrs && enteredMins <= currMins))
					{
						popupTabber.setTabActive('Schedule');
						setValidationMessage(generalMsg[24]);
						document.addAlertFrm.startHours.className = "inputFieldErr";
						document.addAlertFrm.startMins.className = "inputFieldErr";
						isValid =  false ;
						return isValid ;
					}
				}
				else if(enteredDateTemp < currDateInString)
				{
					popupTabber.setTabActive('Schedule');
					setValidationMessage(generalMsg[25]);
					document.addAlertFrm.oneTstartdate.className = "inputFieldErr";
					isValid =  false ;
					return isValid ;
				}
			}
		}
		else
		{
			return isValid;
		}
	}
	// Validation for Daily, Weekly, & Monthly Scheduling
	if((selectedSchedule != 'schedulenow' && selectedSchedule != 'schedNow' && selectedSchedule != "onetimeSchedule"))
	{
		isValid = validateHrs(document.addAlertFrm.startHours);
		if(isValid)
		{
			isValid = validateMins(document.addAlertFrm.startMins);
			if(isValid)
			{
				// Daily validation starts here
				if (selectedSchedule == "dailySchedule")
				{
					if(afterETLObj.checked){
						isValid = true;
					}else{
						isValid = validateDailyScheduleTime(document.addAlertFrm.fromDate,document.addAlertFrm.startHours,document.addAlertFrm.startMins);
					}

					if(isValid)
					{
						if(document.addAlertFrm.fromDate == null || document.addAlertFrm.fromDate.value == ""){
							setValidationMessage(generalMsg[26])
							popupTabber.setTabActive('Schedule');
							document.addAlertFrm.fromDate.className = "inputFieldErr";
							isValid =  false ;
							return isValid ;
						}
						if(document.addAlertFrm.toDate == null || document.addAlertFrm.toDate.value == ""){
							setValidationMessage(generalMsg[27])
							popupTabber.setTabActive('Schedule');
							document.addAlertFrm.toDate.className = "inputFieldErr";
							isValid =  false ;
							return isValid ;
						}
						var enteredFromDate = document.addAlertFrm.fromDate.value ;
						var enteredToDate = document.addAlertFrm.toDate.value ;
						var splitFromDate = enteredFromDate.split("-");
						var splitToDate = enteredToDate.split("-");
						var date1 = new Date(splitFromDate[0],""+((splitFromDate[1])-1),splitFromDate[2]);
						var date2 = new Date(splitToDate[0],""+((splitToDate[1])-1),splitToDate[2]);
						var d = currDateObj;
						var formattedDay = new Date(d.getFullYear(),d.getMonth(),d.getDate());

						if ( date1 < formattedDay)
						{
							setValidationMessage(generalMsg[28])
							popupTabber.setTabActive('Schedule');
							document.addAlertFrm.fromDate.className = "inputFieldErr";
							isValid =  false ;
							return isValid ;
						}
						else if(date2 < formattedDay)
						{
							setValidationMessage(generalMsg[29])
							popupTabber.setTabActive('Schedule');
							document.addAlertFrm.toDate.className = "inputFieldErr";
							isValid =  false ;
							return isValid ;
						}

						if (date1 > date2)
						{
							setValidationMessage(generalMsg[30])
							popupTabber.setTabActive('Schedule');
							document.addAlertFrm.fromDate.className = "inputFieldErr";
							isValid =  false ;
							return isValid ;
						}

						if(date1.getFullYear() == formattedDay.getFullYear() &&
							date1.getMonth() == formattedDay.getMonth() &&
								date1.getDate() == formattedDay.getDate()){
							if((enteredHrs < currDateObj.getHours()) || (enteredHrs == currDateObj.getHours() && enteredMins <= currDateObj.getMinutes()))
							{
								popupTabber.setTabActive('Schedule');
								setValidationMessage(generalMsg[24]);
								document.addAlertFrm.startHours.className = "inputFieldErr";
								document.addAlertFrm.startMins.className = "inputFieldErr";
								isValid =  false ;
								return isValid ;
							}
						}

						for ( var j = 0 ; j < document.addAlertFrm.daily.length ; j++)
						{
							if(document.addAlertFrm.daily[j].checked == true )
							{
								var selectedVal = document.addAlertFrm.daily[j].value ;
								if( selectedVal == "every" )
								{
									document.addAlertFrm.ddays.disabled=false ;
									var dday = document.addAlertFrm.ddays.value;
									var dys = getNoOfDaysInMonth();
									if(dday == "")
									{
										setValidationMessage(generalMsg[31])
										popupTabber.setTabActive('Schedule');
										document.addAlertFrm.ddays.className = "inputFieldErr";
										isValid =  false ;
										return isValid ;
									}
									else if(dday>dys)
									{
										setValidationMessage(generalMsg[32]+' '+dys);
										popupTabber.setTabActive('Schedule');
										document.addAlertFrm.ddays.className = "inputFieldErr";
										isValid =  false ;
										return isValid;
									}
									else if(dday == null || isNaN(dday) || parseInt(dday)<0 || parseInt(dday)>365)
									{
										setValidationMessage(generalMsg[33])
										popupTabber.setTabActive('Schedule');
										document.addAlertFrm.ddays.className = "inputFieldErr";
										isValid =  false ;
										return isValid ;
									}
								}
							}
						}
					}
				} // Weekly validation starts here
				else if (selectedSchedule == "weeklySchedule")
				{
					var weeks = document.addAlertFrm.wweeks.value ;
					if (isNaN(weeks) || weeks == "" || weeks == null || parseInt(weeks)<0 || parseInt(weeks)>52)
					{
						setValidationMessage(generalMsg[34]);
						popupTabber.setTabActive('Schedule');
						document.addAlertFrm.wweeks.className = "inputFieldErr";
						isValid =  false ;
						return isValid ;
					}

					for(i=0;i< document.addAlertFrm.wday.length;i++)
					{
						if(document.addAlertFrm.wday[i].checked == true)
						{
							counter =counter+1;
						}
					}

					if ( counter == 0 )
					{
						setValidationMessage(generalMsg[35]);
						popupTabber.setTabActive('Schedule');

						for(i=0;i< document.addAlertFrm.wday.length;i++)
						{
							document.addAlertFrm.wday[i].className = "inputFieldErrCheck";
						}

						isValid =  false;
						return isValid ;
					}
				}// Monthly validation starts here
				else if(selectedSchedule == "monthlySchedule")
				{
					var selectedMonthlyOption = '';
					for(var ctr=0; ctr<document.addAlertFrm.moption.length; ctr++)
					{
						if(document.addAlertFrm.moption[ctr].checked)
						{
							selectedMonthlyOption = document.addAlertFrm.moption[ctr].value;
						}
					}
					if (selectedMonthlyOption == "dayofmonth")
					{
						if(monthDays == "")
						{
							setValidationMessage(generalMsg[36]);
							document.addAlertFrm.mdom.className = "inputFieldErr";
							popupTabber.setTabActive('Schedule');
							isValid =  false ;
							return isValid ;
						}
						var monthDays = document.addAlertFrm.mdom.value ;
						if ( isNaN(monthDays) || monthDays == "" || monthDays == null || parseInt(monthDays)<0 || parseInt(monthDays)>31 )
						{
							setValidationMessage(generalMsg[37]);
							popupTabber.setTabActive('Schedule');
							document.addAlertFrm.mdom.className = "inputFieldErr";
							isValid =  false ;
							return isValid ;
						}
					}
					if(selectedMonthlyOption == 'dayofweek')
					{
						var mdow1 = document.addAlertFrm.mdow1.options[document.addAlertFrm.mdow1.selectedIndex].value;
						var mdow2 = document.addAlertFrm.mdow2.options[document.addAlertFrm.mdow2.selectedIndex].value;
						if(mdow1.toLowerCase()=='select' || mdow2.toLowerCase()=='select')
						{
							setValidationMessage(generalMsg[35]);
							popupTabber.setTabActive('Schedule');
							document.addAlertFrm.mdow1.className = "inputFieldErrSel";
							document.addAlertFrm.mdow2.className = "inputFieldErrSel";
							isValid =  false ;
							return isValid ;
						}
					}
					var counter = 0;
					for ( var k = 0 ; k < document.addAlertFrm.mmonths.length ; k++ )
					{
						if (document.addAlertFrm.mmonths[k].checked == true  )
						{
							counter = counter+1;
						}
					}
					if(parseInt(counter)==0)
					{
						setValidationMessage(generalMsg[38]);
						popupTabber.setTabActive('Schedule');

						for ( var k = 0 ; k < document.addAlertFrm.mmonths.length ; k++ )
						{
							document.addAlertFrm.mmonths[k].className = "inputFieldErrCheck";
						}

						isValid =  false ;
						return isValid ;
					}

				} // Monthly validation ends here
			}
			else
				return isValid;
		}
		else
			return isValid;
	}

	// delivery tab validation
	if(document.addAlertFrm.dashPortlet.checked ==false && document.addAlertFrm.useremailchk.checked == false)
	{
		setValidationMessage(generalMsg[39])
		popupTabber.setTabActive('delivery');
		isValid = false ;
		return isValid ;
	}

	// check the recipients for email
	counter=0;
	for ( var j =0 ; j < document.addAlertFrm.recipient.length ; j++ )
	{
		if (document.addAlertFrm.recipient[j].checked == true && document.addAlertFrm.useremailchk.checked == true  )
		{
			if (document.addAlertFrm.recipient[j].value == 'role' )
			{
			var selectedRoleCount =0;
					var selectedRoleValues;
					for(i=0;i< mygridrole.getRowsNum();i++){
						if( mygridrole.cells(mygridrole.getRowId(i),0).cell.childNodes[0].checked ){
							var storeValues='';
							//Firefox fix
							storeValues=trim(mygridrole.cells(mygridrole.getRowId(i),0).cell.childNodes[0].value);
							/*if(mygriduser.cells(mygriduser.getRowId(i),0).getValue().split("value=")[1].indexOf("name=")!=-1){
								storeValues=trim(mygriduser.cells(mygriduser.getRowId(i),0).getValue().split("value=")[1].split("name=")[0]);

							}else{
	 							storeValues=trim(mygriduser.cells(mygriduser.getRowId(i),0).getValue().split("value=")[1]);
	 						}
	 						if(storeValues.indexOf("CHECKED")>=0){
								 storeValues=trim(storeValues.split("CHECKED")[0]);
							}*/
	 						if(storeValues!=''){
	 							if(storeValues.indexOf('"')>=0){
									    storeValues=storeValues.replace('"','');
									    storeValues=storeValues.replace('"','');
									    storeValues=trim(storeValues);
			  					  }
	 						}
							if(selectedRoleCount==0 && storeValues!=''){
								selectedRoleValues=storeValues;
							}else if(storeValues!=''){
								selectedRoleValues=selectedRoleValues+"-roleids-"+storeValues;
							}
							counter+=1 ;
							selectedRoleCount+=1 ;
						}
					}
				if ( counter == 0 )
				{
					setValidationMessage(generalMsg[40]);
					popupTabber.setTabActive('recipients');
					isValid =  false;
					return isValid ;
				}else{
					document.addAlertFrm.selectedRole.value=selectedRoleValues;
				}
			} // if loop for user check
			else if (document.addAlertFrm.recipient[j].value == 'user' )
			{
					var selectedRoleCount =0;
					var selectedUserValues;
					for(i=0;i< mygriduser.getRowsNum();i++){
						if( mygriduser.cells(mygriduser.getRowId(i),0).cell.childNodes[0].checked ){
							var storeValues='';
							//Firefox fix
							storeValues=trim(mygriduser.cells(mygriduser.getRowId(i),0).cell.childNodes[0].value);
							/*if(mygriduser.cells(mygriduser.getRowId(i),0).getValue().split("value=")[1].indexOf("name=")!=-1){
								storeValues=trim(mygriduser.cells(mygriduser.getRowId(i),0).getValue().split("value=")[1].split("name=")[0]);

							}else{
	 							storeValues=trim(mygriduser.cells(mygriduser.getRowId(i),0).getValue().split("value=")[1]);
	 						}*/
	 						if(storeValues!=''){
	 							if(storeValues.indexOf('"')>=0){
									    storeValues=storeValues.replace('"','');
									    storeValues=storeValues.replace('"','');
									    storeValues=trim(storeValues);
			  					  }
	 						}
	 						if(storeValues.indexOf("CHECKED")>=0){
								 storeValues=trim(storeValues.split("CHECKED")[0]);
							}
							if(selectedRoleCount==0 && storeValues!=''){
								selectedUserValues=storeValues;
							}else if(storeValues!=''){
								selectedUserValues=selectedUserValues+"-userids-"+storeValues;
							}
							counter+=1 ;
							selectedRoleCount+=1 ;
						}
					}

				if ( counter == 0 )
				{
					setValidationMessage(generalMsg[41]);
					popupTabber.setTabActive('recipients');
					isValid =  false;
					return isValid ;
				}else {
							document.addAlertFrm.selectedUser.value=selectedUserValues;
					}
			}
			else if(document.addAlertFrm.recipient[j].value == 'externalUser')
			{
				if (ValidateFormEmail() == false)
				{
					isValid =  false;
					return isValid ;
				}
			}
		} // if check for recipients
	} // for  loop for recipients ends
	return isValid ;
}

// validate the time for Daily Schedule
function validateDailyScheduleTime(fromDate,hrsObj,minsObj)
{
var isValid = true;

	var enteredDate = fromDate.value;
	var currDate = new Date();

	var cMon = currDate.getMonth()+1;
	var cDay = currDate.getDate();

	var enteredHrs = parseInt(hrsObj.value,10);
	var enteredMins = parseInt(minsObj.value,10);

	var currHrs = currDate.getHours();
	var currMins = currDate.getMinutes();

	if(cMon<=9){
		cMon = "0"+cMon ;
	}
	if(cDay<=9){
		cDay = "0"+cDay ;
	}
	var currDateInString = cDay+"-"+cMon+"-"+currDate.getFullYear();
	if(enteredDate == currDateInString)
	{
		if((enteredHrs < currHrs) || (enteredHrs == currHrs && enteredMins <= currMins))
		{
			popupTabber.setTabActive('Schedule');
			setValidationMessage(generalMsg[24]);
			hrsObj.className = "inputFieldErr";
			minsObj.className = "inputFieldErr";
			isValid =  false ;
			return isValid;
		}else{
			isValid =  true;
			return isValid;
		}
	}else{
		return isValid;
	}
}

// hour validation
function validateHrs(hrsObj)
{
	var hrsVal = hrsObj.value;

	if(hrsVal=="")
	{
			setValidationMessage(generalMsg[42]);
			popupTabber.setTabActive('Schedule');
			addAlertFrm.startHours.className = "inputFieldErr";
			addAlertFrm.startMins.className = "inputField";
			hrsObj.focus();
			return false;
	}
	else if(parseInt(hrsVal)<0 || parseInt(hrsVal)>24 || isNaN(hrsVal))
	{
			setValidationMessage(generalMsg[43]);
			popupTabber.setTabActive('Schedule');
			addAlertFrm.startHours.className = "inputFieldErr";
			addAlertFrm.startMins.className = "inputField";
			hrsObj.focus();
			return false;
	}
	else
		return true;
}

// minute validation
function validateMins(minsObj)
{
	var minVal = minsObj.value;

	if(minVal=="")
	{
			setValidationMessage(generalMsg[44]);
			popupTabber.setTabActive('Schedule');
			addAlertFrm.startMins.className = "inputField";
			addAlertFrm.startMins.className = "inputFieldErr";
			minsObj.focus();
			return false;
	}
	else if(parseInt(minVal)<0 || parseInt(minVal)>59 || isNaN(minVal))
	{
			setValidationMessage(generalMsg[45]);
			popupTabber.setTabActive('Schedule');
			addAlertFrm.startMins.className = "inputField";
			addAlertFrm.startMins.className = "inputFieldErr";
			minsObj.focus();
			return false;
	}
	else
		return true;
}
function getUrlParam(name)
{
	name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
	var regexS = "[\\?&]"+name+"=([^&#]*)";var regex = new RegExp( regexS );
	var results = regex.exec(window.location.href);

	if(results==null)
		return "";
	else
		return results[1];
}
function enableDays(daily,form){
	if ( daily == "every"){
		form.ddays.disabled = false ;
	}
	else if ( daily == "everyday" ){
		form.ddays.disabled = true ;
		form.ddays.value= "";
	}
	else if ( daily == "weekdays"){
		form.ddays.disabled = true ;
		form.ddays.value= "";
	}
}
function checkRuleNew(expressions)
	{
		var pos = '';
		if ( expressions.indexOf('&&') != -1  ){
			pos=expressions.indexOf('&&');
		}
		if ( expressions.indexOf('||') != -1  ){
			pos=expressions.indexOf('||');
		}
		if ( expressions.indexOf('(') != -1  ){
			pos=expressions.indexOf('(');
		}
		if ( expressions.indexOf(')') != -1  ){
			pos=expressions.indexOf(')');
		}
		if ( expressions.indexOf('!=') != -1  ){
			pos=expressions.indexOf('!=');
		}
		if ( expressions.indexOf('==') != -1  ){
			pos=expressions.indexOf('==');
		}
		if ( expressions.indexOf('<') != -1  ){
			pos=expressions.indexOf('<');
		}
		if ( expressions.indexOf('>') != -1  ){
			pos=expressions.indexOf('>');
		}
		if ( expressions.indexOf('+') != -1  ){
			pos=expressions.indexOf('+');
			return pos ;
		}
		if ( expressions.indexOf('-') != -1  ){
			pos=expressions.indexOf('-');
		}
		if ( expressions.indexOf('*') != -1  ){
			pos=expressions.indexOf('*');
		}
		if ( expressions.indexOf('/') != -1  ){
			pos=expressions.indexOf('/');
		}
		var expr = expressions.substring(0,pos+1);
		document.addAlertFrm.leftExpr.value = expr ;
		var expval = expressions.substring(pos+1,expressions.length);
		document.addAlertFrm.rightExpr.value = expval ;
		if ( document.addAlertFrm.exprChk.checked == true ){
			var URL="alertnew?ruleBuilder=yes&expression="+encodeURIComponent(expr)+"&expval="+encodeURIComponent(expval);
			new Ajax.Updater({success: 'ruleBuilder'}, URL, {asynchronous:true, onFailure: reportError, evalScripts: true});
			document.getElementById("ruleBuilder").style.display='block';
		}
		else{
			document.getElementById("ruleBuilder").style.display='none';
			document.getElementById("ruleBuilder").innerHTML = "" ;
		}
	}
	function showRuleBuilder(){
			var URL="alertnew?ruleBuilder=yes";
			new Ajax.Updater({success: 'ruleBuilder'}, URL, {asynchronous:true, onFailure: reportError, evalScripts: true});
	}
function appendToExpcol(obj){
var combo1 = document.getElementById("columns");
var displayText = combo1.options[combo1.selectedIndex].text ;

	var idsExpression = document.expressionFrm.expressionMeasures.value ;
    var val = document.expressionFrm.expressions.value;
	var count = false;
	if(val.length>0){
    var last = val.substring(val.length-1);
	if(last == '=' || last == '<>' || last == '>' || last == '<' ||
		last == '>=' || last == '<=' || last == '+' || last == '-' ||
		last == '*' || last == '/'){
			count = true;
		}
    }

	if(idsExpression.length>0){
    var last = idsExpression.substring(idsExpression.length-1);
	if(last == '=' || last == '<>' || last == '>' || last == '<' ||
		last == '>=' || last == '<=' || last == '+' || last == '-' ||
		last == '*' || last == '/'){
			count = true;
		}
    }
    var flag = false;
    val = val+ " " + displayText;
	document.expressionFrm.expressions.value = val;
	idsExpression = idsExpression + " " + obj.value ;
	document.expressionFrm.expressionMeasures.value = idsExpression;
	parent.document.form1.expressionIds.value = document.expressionFrm.expressionMeasures.value ;
}


function appendToExpoper(obj){
    var val = document.expressionFrm.expressions.value;
	var ids = document.expressionFrm.expressionMeasures.value;
	val = val+ " " + obj.value;
    ids = ids+ " " + obj.value;
	document.expressionFrm.expressions.value = val;
	document.expressionFrm.expressionMeasures.value = ids;
	parent.document.form1.expressionIds.value = document.expressionFrm.expressionMeasures.value ;
		//appendToOutput();
}
function setValidationMessage( msg ){
	parent.document.getElementById('mandatorySection').innerHTML = "<font style='color:red;'>"+msg+"</font>";
	//redTimer = setTimeout("parent.document.getElementById('mandatorySection').innerHTML ='';clearTimeout(redTimer);","10000");

}
function clearMessages(){
	parent.document.getElementById('mandatorySection').innerHTML = "" ;
}
function maskKeyPress(objEvent, obj)
    {
    	var iKeyCode;
		iKeyCode = objEvent.keyCode;

		if(iKeyCode == 13){
			appendToExpval(obj);
			obj.value="";
			return false;
		}

    }
function appendToExpval(obj)
 {
    var num = document.expressionFrm.valueText.value;
	if (isNaN(num) == true || document.expressionFrm.valueText.value.length==0)
	{
       alert(generalMsg[46]);
	   document.expressionFrm.valueText.value="";
	   document.expressionFrm.valueText.focus();
	}else
	{
	   var val = document.expressionFrm.expressions.value;
	   var ids = document.expressionFrm.expressionMeasures.value;
	   var count = false;
	   if(val.length>0){
		var last = val.substring(val.length-1);
		if(last == '=' || last == '!=' || last == '>' || last == '<' ||
			last == '>=' || last == '<=' || last == '+' || last == '-' ||
			last == '*' || last == '/'){
				count = true;
			}
		}

	if(ids.length>0){
    var last = ids.substring(ids.length-1);
	if(last == '=' || last == '<>' || last == '>' || last == '<' ||
		last == '>=' || last == '<=' || last == '+' || last == '-' ||
		last == '*' || last == '/'){
			count = true;
		}
    }
		val = val+ " " + num;
		ids = ids+ " " + obj.value;
		document.expressionFrm.expressions.value = val;
		document.expressionFrm.expressionMeasures.value = ids;
		parent.document.form1.expressionIds.value = document.expressionFrm.expressionMeasures.value ;
	}
}
function appendMeasureIds(obj){
	var measureIds = parent.document.form1.measureIds.value;
	measureIds=measureIds+obj.value+",";
	parent.document.form1.measureIds.value = measureIds ;
}
function addMeasureExpressions( expressions , measureExp ){
	var url="arcui?nav_action=KPIPUB_MEASURE_EXPRESSIONS&expressions="+expressions+"&measureExpression="+measureExp;
	var myAjax = new Ajax.Request(url,
	{
		method: 'post',
		onComplete: updateColumns
	}
	);
}
/* chandra ends here */
/*ADMIN MENU BAR STARTS*/
var currMenuToolClass='';
function adonMenuToolConfig(div)
{
	currMenuToolClass = div.className;
	div.className='admenuBarConfigActive';
}
function adoffMenuToolConfig(div)
{
	div.className=currMenuToolClass;
}

var currMenuBarClass=''
var currParentMenuBarClass=''
function adonMenuBar(div)
{
	currMenuBarClass = div.className;
	currParentMenuBarClass = div.parentNode.className;
	div.className='admenuBarLeftHigh';
	div.parentNode.className='admenuBarRight_MHigh';
}
function adoffMenuBar(div)
{
	div.className=currMenuBarClass;
	div.parentNode.className=currParentMenuBarClass;
}

function adchangeMenuState(val){
	for(i=0; i<val.parentNode.parentNode.childNodes.length-1; i++){
		if(val.parentNode.parentNode.childNodes[i].innerHTML!=null){
			val.parentNode.parentNode.childNodes[i].className='admenuBarRight_M';
			if (isNav && !isIE){
				if(val.parentNode.parentNode.childNodes[i].childNodes[0]!=null){
					val.parentNode.parentNode.childNodes[i].childNodes[0].className='admenuBarLeft';
				}
				if(val.parentNode.parentNode.childNodes[i].childNodes[0].onmouseout==null)
				{
					val.parentNode.parentNode.childNodes[i].childNodes[0].onmouseover = function() {adonMenuBar(this)};
					val.parentNode.parentNode.childNodes[i].childNodes[0].onmouseout = function() {adoffMenuBar(this)};
					val.parentNode.parentNode.childNodes[i].childNodes[0].onclick = function() {changeMenuState(this)};
				}
			}
			else if (isIE && !isNav)
			{
				val.parentNode.parentNode.childNodes[i].childNodes[0].className='admenuBarLeft';
				if(val.parentNode.parentNode.childNodes[i].childNodes[0].onmouseout==null)
				{
					val.parentNode.parentNode.childNodes[i].childNodes[0].onmouseover = function() {adonMenuBar(this)};
					val.parentNode.parentNode.childNodes[i].childNodes[0].onmouseout = function() {adoffMenuBar(this)};
					val.parentNode.parentNode.childNodes[i].childNodes[0].onclick = function() {changeMenuState(this)};
				}
			}
		}
	}
	val.className='admenuBarLeftActive';
	val.parentNode.className='admenuBarRightActive_M';
	val.onmouseout= null;
	val.onmouseover= null;
}

/*ADMIN MENU BAR ENDS*/
function onBlurFunc1()
{
	if(document.getElementById('popUpFrame1') && document.getElementById('popUpFrame1').style.display=='block')
	{
		document.getElementById('popUpFrame1').focus();
	}
	return true;
}
function invokePopup1(val, val2, val3, val4, val5)
{
	if(document.getElementById('winLoader')){document.getElementById('winLoader').style.display='block';}
	var allTopDivs= parent.document.getElementsByTagName("div");
	for(i=0; i<allTopDivs.length; i++)
	{
		if(allTopDivs[i].className=="buttonBlueRight_M"  || allTopDivs[i].className=="buttonBlueActiveRight_M"){
			allTopDivs[i].style.display='none';
		}
	}

	if(BrowserDetect.OS=='Mac' && BrowserDetect.browser=='Firefox'){
		if(parent.portalFrame){
			var allEmbedObj = parent.portalFrame.document.getElementsByTagName("embed");
		}
		else if($('portalFrame') && $('portalFrame').src.indexOf("fromAdmin")> -1){
			var allEmbedObj = portalFrame.document.getElementsByTagName("embed");
		}
		else{
			var allEmbedObj = parent.document.getElementsByTagName("embed");
		}
		for(i=0; i<allEmbedObj.length; i++){
					allEmbedObj[i].style.display='none';
		}
	}

	document.getElementById('popUpFrame1').setAttribute("onblur", onBlurFunc1);
	document.getElementById('popUpIframe1').style.position = 'absolute';
	document.getElementById('popUpIframe1').style.top = '0px';
	document.getElementById('popUpIframe1').style.left = '0px';
	document.getElementById('popUpIframe1').style.width = '100%';
	document.getElementById('popUpIframe1').style.backgroundColor = '#ffffff';
	if (BrowserDetect.browser=="Firefox")
	{
		document.getElementById('popUpIframe1').style.height = window.innerHeight + window.scrollMaxY + "px";
		document.getElementById('popUpIframe1').style.opacity = '0.7';
		document.getElementById('popUpIframe1').style.display='block';
	}
	else if (BrowserDetect.browser=="Explorer")
	{
		document.getElementById('popUpIframe1').style.height = (document.body.clientHeight) + "px";
		document.getElementById('popUpIframe1').style.filter = 'alpha(opacity=70)';
		document.getElementById('popUpIframe1').style.display='block';
	}

	if(val3!="*,*")
	{
		val3 = val3.split(",");
		document.getElementById('popUp1').style.top = val3[0] +"px";
		document.getElementById('popUp1').style.left = val3[1] +"px";
	}
	else
	{
		document.getElementById('popUp1').style.top = (window.screen.height/2)  +"px";
		document.getElementById('popUp1').style.left = (window.screen.width/2)  -  val4 +"px";
	}

	if (BrowserDetect.browser!="Firefox")
	{
		invokePop_dragDown("popUp1","popupNav1");
	}

	if (BrowserDetect.browser=="Firefox"){
		 window.scroll(0,val3[0]);
	}

	document.getElementById('popUp1').style.display='block';
	document.getElementById('popUp1').style.zIndex='999';
	document.getElementById('popUp1').style.width = val5 +"%";
	document.getElementById('popUp1').focus();
	val2=(val2.indexOf("?")>=0)?(val2.split("?")[0]+"?timeStamp="+new Date().getUTCMilliseconds()+"&"+val2.split("?")[1]):(val2+"?timeStamp="+new Date().getUTCMilliseconds());
	document.getElementById('popUpFrame1').src =val2;
	document.getElementById('popUpFrame1').height =val4 +"px";
	document.getElementById('popUpName1').innerHTML = val;
}

function killPopup1()
{
	if(document.getElementById('winLoader')){document.getElementById('winLoader').style.display='none';}
	var allTopDivs= parent.document.getElementsByTagName("div");
	for(i=0; i<allTopDivs.length; i++)
	{
		if(allTopDivs[i].className=="buttonBlueRight_M"  || allTopDivs[i].className=="buttonBlueActiveRight_M"){
			allTopDivs[i].style.display='block';
		}
	}
	if(BrowserDetect.OS=='Mac' && BrowserDetect.browser=='Firefox'){

		if(parent.portalFrame){
			var allEmbedObj = parent.portalFrame.document.getElementsByTagName("embed");
		}
		else if($('portalFrame') && $('portalFrame').src.indexOf("fromAdmin")> -1){
			var allEmbedObj = portalFrame.document.getElementsByTagName("embed");
		}
		else{
			var allEmbedObj = parent.document.getElementsByTagName("embed");
		}
		for(i=0; i<allEmbedObj.length; i++){
			allEmbedObj[i].style.display='block';
		}
	}

	document.getElementById('popUpFrame1').removeAttribute("onblur");
	document.getElementById('popUpFrame1').src='';
	document.getElementById('mandatorySection1').innerHTML='';
	document.getElementById('popUpIframe1').style.display='none';
	document.getElementById('popUp1').style.display='none';
	document.getElementById('poupButtons1').innerHTML="";
	document.body.removeChild(document.getElementById("iframefix"));
}

function escPopup1(e)
{
      var kC  = (window.event) ?    // MSIE or Firefox?
                 event.keyCode : e.keyCode;
      var Esc = (window.event) ?
                27 : e.DOM_VK_ESCAPE // MSIE : Firefox
      if(kC==Esc)
		var closeCheck = confirm(generalMsg[4]);

		if(closeCheck)
		{
		 parent.killPopup1();
		}
}
function escPopup2(e)
{
      var kC  = (window.event) ?    // MSIE or Firefox?
                 event.keyCode : e.keyCode;
      var Esc = (window.event) ?
                27 : e.DOM_VK_ESCAPE // MSIE : Firefox
      if(kC==Esc)
		var closeCheck = confirm(generalMsg[4]);
		if(closeCheck)
		{
		 killPopup();
		}
}

/* Search XML*/


function treeClick()
{
	if (document.all)
	document.onselectstart =
	function () { return false; };
}

function stripCharacter(words,character) {
  var spaces = words.length;
  for(var x = 1; x<spaces; ++x)
   {
  	 words = words.replace(character, "");
   }
 return words;
}
/* Cross browser XML DOM starts*/
function loadXmlFromUrl(url) {
	var xmlDoc = null;
	if(window.ActiveXObject) {
		xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
		xmlDoc.async=false;
		xmlDoc.load(url);
		return xmlDoc.documentElement;
	}
	else if(window.XMLHttpRequest) {
		xmlDoc = new XMLHttpRequest();
		xmlDoc.open("GET", url, false);
		xmlDoc.send(null);// this line is required in firefox
		return xmlDoc.responseXML;
	}
}

function convertStrToXMLDom(theString) {
	if(window.ActiveXObject) {
		var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
		xmlDoc.async=false;
		xmlDoc.loadXML(theString);
		return xmlDoc;
	}
	else if(window.DOMParser) {
		var parser = new DOMParser();
		return parser.parseFromString(theString, "text/xml");
	}
}

function serializeDomToXml(xmlDoc){
	if (BrowserDetect.browser!="Firefox")
		return xmlDoc.xml
	else
		return (new XMLSerializer()).serializeToString(xmlDoc);
}
/* Cross browser XML DOM ends*/

function replaceCharactersForToolTip(toolTip){
	if(toolTip && toolTip!=''){
		toolTip = toolTip.replace(/&/g,'and');
		toolTip = toolTip.replace(/</g,'&lt;');
		toolTip = toolTip.replace(/>/g,'&gt;');
		toolTip = toolTip.replace(/\(/g,'[');
		toolTip = toolTip.replace(/\)/g,']');
		toolTip = toolTip.replace(/null/g,'');
	}
	return toolTip;
}
function traverse(val, url, tree, field) {
	val = stripCharacter(val,"\\");
	val = stripCharacter(val,"*");
	val = val.replace(/\(/,'{');
	val = val.replace(/\)/,'}');

	if(val.length>=3 || val.length==0)
	{
		var selectFlag=true;
		tree.enableDistributedParsing(false,10,50);


		//FireFox fix for search engine
		/*var xmlDocs = new ActiveXObject("Microsoft.XMLDOM");
		var xmlFormedNode = new ActiveXObject("Microsoft.XMLDOM")

		xmlDocs.load(url);
		xmlDocs.onreadystatechange = function ()*/


				var xmlObj = loadXmlFromUrl(url);
				var nodes=xmlObj.childNodes;
				var xmlNodeString = "";
				var xmlNodeString1 = " ";
				var xmlNodeString2 = " ";
				var xmlNodeString3 = " ";
				var dashboardFlag = true;
				results = new Array;
				var returnFlag = 0;

				for(var i=0; i<nodes.length; i++)
				{
					var name1 = serializeDomToXml(nodes[i]);
					var exp1 = new RegExp(val,"i");
					name1 = name1.replace(/\(/g,'{');
					name1 = name1.replace(/\)/g,'}');
					if ( name1.match(exp1) != null)
					{
						if(nodes[i].getAttribute('id')=="DM")
						{
							dashboardFlag=false;
						}
						if(nodes[i].getAttribute('im0')!=null)			{
							xmlNodeString = '<item text="'+nodes[i].getAttribute('text')+'" tooltip="'+replaceCharactersForToolTip(nodes[i].getAttribute('tooltip'))+'" id="'+nodes[i].getAttribute('id')+'" im0="'+nodes[i].getAttribute('im0')+'" im1="'+nodes[i].getAttribute('im1')+'" im2="'+nodes[i].getAttribute('im2')+'">';
							if(selectFlag)	selectFlag=false;
						}
						else		{
							xmlNodeString = '<item text="'+nodes[i].getAttribute('text')+'" tooltip="'+replaceCharactersForToolTip(nodes[i].getAttribute('tooltip'))+'" id="'+nodes[i].getAttribute('id')+'">';
							if(selectFlag)	selectFlag=false;
						}
						innerNode = nodes[i].childNodes;
						for(j=0; j<innerNode.length; j++)
						{
							var name2 = serializeDomToXml(innerNode[j]);
							name2 = name2.replace(/\(/g,'{');
							name2 = name2.replace(/\)/g,'}');
							var exp2 = new RegExp(val,"i");
							if ( name2.match(exp2) != null)
							{
								if(innerNode[j].getAttribute('im0')!=null)
								{
									xmlNodeString1 = '<item text="'+innerNode[j].getAttribute('text')+'" tooltip="'+replaceCharactersForToolTip(innerNode[j].getAttribute('tooltip'))+'" id="'+innerNode[j].getAttribute('id')+'" im0="'+innerNode[j].getAttribute('im0')+'" im1="'+innerNode[j].getAttribute('im1')+'" im2="'+innerNode[j].getAttribute('im2')+'">';
								}
								else
								{
									xmlNodeString1 = '<item text="'+innerNode[j].getAttribute('text')+'" tooltip="'+replaceCharactersForToolTip(innerNode[j].getAttribute('tooltip'))+'" id="'+innerNode[j].getAttribute('id')+'">';
								}
								innerNode1 = innerNode[j].childNodes;
								for(k=0; k<innerNode1.length; k++)
								{
									var name3 = serializeDomToXml(innerNode1[k]);
									name3 = name3.replace(/\(/g,'{');
									name3 = name3.replace(/\)/g,'}');
									var exp3 = new RegExp(val,"i");
									if ( name3.match(exp3) != null)
									{
										if(innerNode1[k].getAttribute('im0')!=null)
										{
											xmlNodeString2 = '<item text="'+innerNode1[k].getAttribute('text')+'" tooltip="'+replaceCharactersForToolTip(innerNode1[k].getAttribute('tooltip'))+'" id="'+innerNode1[k].getAttribute('id')+'" im0="'+innerNode1[k].getAttribute('im0')+'" im1="'+innerNode1[k].getAttribute('im1')+'" im2="'+innerNode1[k].getAttribute('im2')+'">';
										}
										else
										{
											xmlNodeString2 = '<item text="'+innerNode1[k].getAttribute('text')+'" tooltip="'+replaceCharactersForToolTip(innerNode1[k].getAttribute('tooltip'))+'" id="'+innerNode1[k].getAttribute('id')+'">';
										}
										innerNode2 = innerNode1[k].childNodes;
										for(l=0; l<innerNode2.length; l++)
										{
											var name4 = serializeDomToXml(innerNode2[l]);
											name4 = name4.replace(/\(/g,'{');
											name4 = name4.replace(/\)/g,'}');
											var exp4 = new RegExp(val,"i");
											if (name4.match(exp4) != null)
											{
												xmlNodeString3 = serializeDomToXml(innerNode2[l]);
												if(xmlNodeString3!="")
												{
													xmlNodeString2 = xmlNodeString2 + xmlNodeString3;
												}
											}
											else
											{
												if(innerNode2[l].parentNode.childNodes[0] && innerNode2[l].parentNode.getAttribute('text').match(exp4)!=null)
												{
													xmlNodeString2= xmlNodeString2 + serializeDomToXml(innerNode2[l]);
												}
											}
										}
										xmlNodeString2 = xmlNodeString2 + "</item>";
										if(xmlNodeString2!="")
										{
											xmlNodeString1 = xmlNodeString1 + xmlNodeString2;
										}
									}
									else
									{
										if(innerNode1[k].parentNode.childNodes[0] && innerNode1[k].parentNode.getAttribute('text').match(exp3)!=null)
										{
											xmlNodeString1= xmlNodeString1 + serializeDomToXml(innerNode1[k]);
										}
									}
								}
								xmlNodeString1 = xmlNodeString1 + "</item>";
								if(xmlNodeString1!="")
								{
									xmlNodeString = xmlNodeString + xmlNodeString1;
								}
							}
							else
							{
								if(innerNode[j].parentNode.childNodes[0] && innerNode[j].parentNode.getAttribute('text') && innerNode[j].parentNode.getAttribute('text').match(exp2)!=null)
								{
									xmlNodeString= xmlNodeString + serializeDomToXml(innerNode[j]);
								}
							}
						}
						xmlNodeString = xmlNodeString + "</item>";
						xmlNodeString = xmlNodeString.replace(/&/g,'and');
						xmlNodeString = xmlNodeString.replace(/< /g,'&lt;');
						xmlNodeString = xmlNodeString.replace(/ >/g,'&gt;');
						xmlNodeString = xmlNodeString.replace(/\(/g,'[');
						xmlNodeString = xmlNodeString.replace(/\)/g,']');
						xmlNodeString = xmlNodeString.replace(/null/g,'');

						//FireFox fix for search engine
						/*var xmlFormedNode.loadXML(xmlNodeString);
						xmlFormedObj = xmlFormedNode.documentElement;
						results.push(xmlFormedObj);*/
						results.push(convertXmlFromStr(xmlNodeString).documentElement);

						returnFlag = returnFlag+1;
					}

					if(nodes[i].getAttribute('id')=="DM" && dashboardFlag==true)
					{
						//FireFox fix for search engine
						/*var xmlFormedNode.loadXML(serializeDomToXml(nodes[i]));
						xmlFormedObj = xmlFormedNode.documentElement;*/
						results.push(convertXmlFromStr(serializeDomToXml(nodes[i])));
					}
				}

				if(returnFlag>=1)
				{
					formNewXML(results, tree, val);
				}
				else
				{
					document.getElementById(field).value = generalMsg[68];
					document.getElementById(field).focus();
					document.getElementById(field).select();
				}

	}
}

function traverseDirectXML(val, url, tree, field) {
	val = stripCharacter(val,"\\");
	val = stripCharacter(val,"*");
	val = val.replace(/\(/,'{');
	val = val.replace(/\)/,'}');
	if(val.length>=3 || val.length==0)
	{
		var selectFlag=true;
		tree.enableDistributedParsing(false,10,50);
		var xmlDocs = new ActiveXObject("Microsoft.XMLDOM");
		var xmlFormedNode = new ActiveXObject("Microsoft.XMLDOM")

		xmlDocs.loadXML(url);

		xmlObj = xmlDocs.documentElement;
		var nodes=xmlObj.childNodes;
		var xmlNodeString = "";
		var xmlNodeString1 = " ";
		var xmlNodeString2 = " ";
		var xmlNodeString3 = " ";
		var dashboardFlag = true;
		results = new Array;
		var returnFlag = 0;

		for(var i=0; i<nodes.length; i++)
		{
			var name1 = nodes[i].xml;
			name1 = name1.replace(/\(/g,'{');
			name1 = name1.replace(/\)/g,'}');
			var exp1 = new RegExp(val,"i");

			if ( name1.match(exp1) != null)
			{
				if(nodes[i].getAttribute('id')=="DM")
				{
					dashboardFlag=false;
				}
				if(nodes[i].getAttribute('im0')!=null)
				{
					if(selectFlag)
					{
						xmlNodeString = "<item text='"+nodes[i].getAttribute('text')+"' tooltip='"+nodes[i].getAttribute('tooltip')+"' id='"+nodes[i].getAttribute('id')+"' im0='"+nodes[i].getAttribute('im0')+"' im1='"+nodes[i].getAttribute('im1')+"' im2='"+nodes[i].getAttribute('im2')+"'>";
						selectFlag=false;
					}
					else
					{
						xmlNodeString = "<item text='"+nodes[i].getAttribute('text')+"' tooltip='"+nodes[i].getAttribute('tooltip')+"' id='"+nodes[i].getAttribute('id')+"' im0='"+nodes[i].getAttribute('im0')+"' im1='"+nodes[i].getAttribute('im1')+"' im2='"+nodes[i].getAttribute('im2')+"'>";
					}
				}
				else
				{
					if(selectFlag)
					{
						xmlNodeString = "<item text='"+nodes[i].getAttribute('text')+"' tooltip='"+nodes[i].getAttribute('tooltip')+"' id='"+nodes[i].getAttribute('id')+"'>";
						selectFlag=false;
					}
					else
					{
						xmlNodeString = "<item text='"+nodes[i].getAttribute('text')+"' tooltip='"+nodes[i].getAttribute('tooltip')+"' id='"+nodes[i].getAttribute('id')+"'>";
					}
				}
				innerNode = nodes[i].childNodes;
				for(j=0; j<innerNode.length; j++)
				{
					var name2 = innerNode[j].xml;
					name2 = name2.replace(/\(/g,'{');
					name2 = name2.replace(/\)/g,'}');
					var exp2 = new RegExp(val,"i");
					if ( name2.match(exp2) != null)
					{
						if(innerNode[j].getAttribute('im0')!=null)
						{
							xmlNodeString1 = "<item text='"+innerNode[j].getAttribute('text')+"' tooltip='"+innerNode[j].getAttribute('tooltip')+"' id='"+innerNode[j].getAttribute('id')+"' im0='"+innerNode[j].getAttribute('im0')+"' im1='"+innerNode[j].getAttribute('im1')+"' im2='"+innerNode[j].getAttribute('im2')+"'>";
						}
						else
						{
							xmlNodeString1 = "<item text='"+innerNode[j].getAttribute('text')+"' tooltip='"+innerNode[j].getAttribute('tooltip')+"' id='"+innerNode[j].getAttribute('id')+"'>";
						}
						innerNode1 = innerNode[j].childNodes;
						for(k=0; k<innerNode1.length; k++)
						{
							var name3 = innerNode1[k].xml;
							name3 = name3.replace(/\(/g,'{');
							name3 = name3.replace(/\)/g,'}');
							var exp3 = new RegExp(val,"i");
							if ( name3.match(exp3) != null)
							{
								if(innerNode1[k].getAttribute('im0')!=null)
								{
									xmlNodeString2 = "<item text='"+innerNode1[k].getAttribute('text')+"' tooltip='"+innerNode1[k].getAttribute('tooltip')+"' id='"+innerNode1[k].getAttribute('id')+"' im0='"+innerNode1[k].getAttribute('im0')+"' im1='"+innerNode1[k].getAttribute('im1')+"' im2='"+innerNode1[k].getAttribute('im2')+"'>";
								}
								else
								{
									xmlNodeString2 = "<item text='"+innerNode1[k].getAttribute('text')+"' tooltip='"+innerNode1[k].getAttribute('tooltip')+"' id='"+innerNode1[k].getAttribute('id')+"'>";
								}
								innerNode2 = innerNode1[k].childNodes;
								for(l=0; l<innerNode2.length; l++)
								{
									var name4 = innerNode2[l].xml;
										name4 = name4.replace(/\(/g,'{');
										name4 = name4.replace(/\)/g,'}');
									var exp4 = new RegExp(val,"i");
									if (name4.match(exp4) != null)
									{
										xmlNodeString3 = innerNode2[l].xml;
										if(xmlNodeString3!="")
										{
											xmlNodeString2 = xmlNodeString2 + xmlNodeString3;
										}
									}
									else
									{
										if(innerNode2[l].parentNode.childNodes[0] && innerNode2[l].parentNode.getAttribute('text').match(exp4)!=null)
										{
											xmlNodeString2= xmlNodeString2 + innerNode2[l].xml;
										}
									}
								}
								xmlNodeString2 = xmlNodeString2 + "</item>";
								if(xmlNodeString2!="")
								{
									xmlNodeString1 = xmlNodeString1 + xmlNodeString2;
								}
							}
							else
							{
								if(innerNode1[k].parentNode.childNodes[0] && innerNode1[k].parentNode.getAttribute('text').match(exp3)!=null)
								{
									xmlNodeString1= xmlNodeString1 + innerNode1[k].xml;
								}
							}
						}
						xmlNodeString1 = xmlNodeString1 + "</item>";
						if(xmlNodeString1!="")
						{
							xmlNodeString = xmlNodeString + xmlNodeString1;
						}
					}
					else
					{
						if(innerNode[j].parentNode.childNodes[0] && innerNode[j].parentNode.getAttribute('text').match(exp2)!=null)
						{
							xmlNodeString= xmlNodeString + innerNode[j].xml;
						}
					}
				}
				xmlNodeString = xmlNodeString + "</item>";
				xmlNodeString = xmlNodeString.replace(/&/g,'and');
				xmlFormedNode.loadXML(xmlNodeString);
				xmlFormedObj = xmlFormedNode.documentElement;
				results.push(xmlFormedObj);
				returnFlag = returnFlag+1;
			}

			if(nodes[i].getAttribute('id')=="DM" && dashboardFlag==true)
			{
				xmlFormedNode.loadXML(nodes[i].xml);
				xmlFormedObj = xmlFormedNode.documentElement;
				results.push(xmlFormedObj);
			}
		}

		if(returnFlag>=1)
		{
			formNewXML(results, tree, val);
			document.getElementById(field).focus();
			document.getElementById(field).select();
		}
		else
		{
			document.getElementById(field).value = generalMsg[68];
			document.getElementById(field).focus();
			document.getElementById(field).select();
		}
	}
}

function formNewXML(val, tree, val1)
{

	//FireFox fix for search engine
	if (BrowserDetect.browser!="Firefox"){
	var xmlNewDocs = new ActiveXObject("Microsoft.XMLDOM");
	xmlNewDocs.load("dhtmlX/codebaseTree/dummySearchXML.xml");
	xmlNewDocs.onreadystatechange = function ()
	{
		if (xmlNewDocs.readyState == 4)
		{
			for(i=0; i<val.length; i++)
			{
				element = xmlNewDocs.childNodes[1].appendChild(val[i]);
			}
			tree.deleteChildItems(0);
			tree.loadXMLString(xmlNewDocs.xml);
			//tree.enableDistributedParsing(true,10,50);
			if(val1!="")
			{
				tree.openAllItems(0);
			}
		}
	};
}
	else {
		var strConcat = '';
		for(i=0; i<val.length; i++)	{
			strConcat += serializeDomToXml(val[i]);
		}
		tree.deleteChildItems(0);
		tree.loadXMLString(strConcat);
		tree.enableDistributedParsing(true,10,50);
		if(val1!=""){
			tree.openAllItems(0);
		}
	}
}


var selEnt=false;
//chitta:for measure,dimension history search on typing text box
var arcGsearch={
	selNode:0,
	thispageform:null,
	gsearchxmlFileName:"",
	getResultId:"",
	gsearchText:"",
	gsearchArray:"",
	gsearchXmlDoc:null,
	dhtmlxTreeObj:null,
	setCursorPosForFF:0,
	$:function(){
	  var arcGsearchElements = new Array();
		for ( var i = 0; i < arguments.length; i++) {
			var arcGsearchElement = arguments[i];
			if (typeof arcGsearchElement != null
					&& typeof arcGsearchElement == 'string')
		  arcGsearchElement = document.getElementById(arcGsearchElement);
			if (arguments.length == 1)
				return arcGsearchElement;
		arcGsearchElements.push(arcGsearchElement);
		}
		return arcGsearchElements;
	},
	showResult:function (txtObj,e,exp,allMes){
		if (!exp) {
			if ( allMes && allMes == 'allMeas') {
				var resSet = "";
				if (txtObj.value.length < 3) {
					getCurrentVal = "";
					tmpgetCurrentVal = "";
				}
				str = getSearchText1(txtObj.value, getCurrentVal);
				if (str.length > 0) {
					if (document.implementation
							&& document.implementation.createDocument
							&& txtObj.id != 'searchString') {
						resSet = this.gsearchXmlDoc.evaluate("//@"
								+ this.gsearchText, this.gsearchXmlDoc, null,
								XPathResult.ANY_TYPE, null);
						resSet = this.getSearchValFF(resSet, str);
					} else if (txtObj.value != "" && txtObj.value.length > 1) {
						resSet = this.getSearchVal(this.gsearchXmlDoc
								.selectNodes("//@" + this.gsearchText), str,
								str.length);
					}
				}
				if (resSet == "")
					getCurrentVal = txtObj.value;
			} else {
				if (txtObj.id == "searchString") {// for KPIBROWSER SEARCH
					var resSet = "";
					for (i = 0; i < allMes.split(",").length; i++) {
						if (allMes.split(",")[i].toLowerCase().indexOf(
								txtObj.value.toLowerCase()) == 0) {
							resSet += allMes.split(",")[i] + ",";
						}
					}
					allMes = txtObj.id;
				} else{
					resSet = "";
					if(BrowserDetect.browser=="Explorer"){
						resSet = this.getSearchVal(this.gsearchXmlDoc
								.selectNodes("//@" + this.gsearchText), txtObj.value,
								txtObj.value.length);
					}
					else{
						resSet = this.gsearchXmlDoc.evaluate("//@"
									+ this.gsearchText, this.gsearchXmlDoc, null,
									XPathResult.ANY_TYPE, null);
						resSet = this.getSearchValFF(resSet, txtObj.value);
					}
				}
			}
		} else {
			var resSet = allMes;
		}
		this.gsearchArray=resSet;
		if (txtObj.value.length > 1
				&& this.buildResultText(resSet, exp, allMes).length >= 1) {
			this.$(this.getResultId).innerHTML = this.buildResultText(resSet,
					exp, allMes);
			this.$(this.getResultId).style.display="block";
			this.$(this.getResultId).style.height="200px";
			this.$(this.getResultId).style.zIndex="9";
			//FireFox Fix for selectionStart
			var caretPos = null;
			if(BrowserDetect.browser=="Explorer")
				caretPos = document.selection.createRange().boundingLeft;
			else
				caretPos = (txtObj.selectionStart*7);
			if (exp || allMes == 'allMeas') {
				this.$(this.getResultId).style.left = caretPos + "px";
				if ((this.$(this.getResultId).offsetLeft + this
						.$(this.getResultId).offsetWidth) >= document
						.getElementById('expressionsArea').offsetWidth) {
					this.$(this.getResultId).style.left = this
							.$(this.getResultId).offsetLeft
							- ((this.$(this.getResultId).offsetLeft + this
									.$(this.getResultId).offsetWidth) - document
									.getElementById('expressionsArea').offsetWidth)
							+ "px";
				}

			}

		} else {
			this.closeBox();
		}
		var evt=window.event?window.event.keyCode:e.which;
		//alert('Now the Event::'+evt+' but globalCursorPos::'+globalCursorPos+'(globalCursorPos*7)::'+(globalCursorPos*7));
		if (evt == 40 && typeof (this.$(arcGsearch.getResultId).childNodes[0]) != 'undefined') {
			this.$(arcGsearch.getResultId).childNodes[0].focus();
			this.$(arcGsearch.getResultId).childNodes[0].className="sr";
			if( BrowserDetect.browser!="Explorer" && allMes && allMes=='allMeas' ){
				//alert(globalCursorPos+'/'+txtObj.selectionStart+'/'+(txtObj.selectionStart*7));
				//alert('setCursorPosForFF::'+setCursorPosForFF);
				txtObj.selectionStart = setCursorPosForFF;
				this.$(this.getResultId).style.left = txtObj.selectionStart*7 + "px";
				globalCursorPos = setCursorPosForFF;
			}
		}
		return true;
	},
	getSearchValFF : function(resSet, str) {

		var result = resSet.iterateNext();
		var addStr = '';
		while (result) {
			var nv = result.childNodes[0].nodeValue.substring(0,str.length).toLowerCase();
			var st = str.toLowerCase();
			if (nv == st) {
				addStr += result.childNodes[0].nodeValue + ",";
			} else if ( st.indexOf("*") == 0	&& sL>=4
				&& result.childNodes[0].nodeValue.toLowerCase().indexOf(st.split("*")[1]) >= 0) {
				addStr += result.childNodes[0].nodeValue + ",";
			}
			result = resSet.iterateNext();
		}
		return addStr;
	},
	getSearchVal : function(tO, sV, sL) {
		var str = "";
		for (j = 0; j < tO.length; j++) {
			var nv = tO[j].value.substring(0, sL).toLowerCase();
			var st = sV.toLowerCase();
			if (nv == st) {
				str += tO[j].value + ",";
			} else if (st.indexOf("*") == 0 && sL >= 4
					&& tO[j].value.toLowerCase().indexOf(st.split("*")[1]) >= 0) {
				str += tO[j].value + ",";
			}
		}
		return str;
	},
	 buildResultText:function(arrVal,exp,allMes){
		var hSr = "";
		if (arrVal.length < 1)
			return hSr;

		 for(i=0;i<arrVal.split(",").length;i++){
			if (!exp) {
			 	var imgVla = "";
				   imgVla = "<image src='images/measure.gif' border='0' align='ablmiddle'/>&nbsp;";
			    if(allMes=='allMeas'){
					if (arrVal.split(",")[i] != "") {
						hSr += "<a href='javascript:void(0);' class='srl' onclick='tempVal=getObjInnerText(this); tempVal=tempVal.split(\" [\"); finalVal = (tempVal[0]).substring(0,tempVal[0].length); if(finalVal==\"(Entity})\"){finalVal=\"{Entity}\"}; clickFlag = false; fillResultArea(document.getElementById(\"expressionsArea\"), \"\"+finalVal+\"\",\"allMeas\"); document.getElementById(\"expressionsArea\").focus(); arcGsearch.closeBox();'>"
								+ imgVla + arrVal.split(",")[i] + "</a>";
					}
			    }else{
			       if(allMes=="searchString"){// for KPIbrowser listing
						if (arrVal.split(",")[i] != "") {
							hSr += "<a href='javascript:void(0);' class='srl' onclick='javascript:this.parentNode.parentNode.childNodes[0].value=getObjInnerText(this);searchKPIs(\"kpiBrowserListing\", this.parentNode.parentNode.childNodes[0], \"tempKPIBrowserListing\");arcGsearch.closeBox();'>"
									+ arrVal.split(",")[i] + "</a>";
						}
					} else if (arrVal.split(",")[i] != "") {
						hSr += "<a href='javascript:void(0);' class='srl' onclick='javascript:Element.cleanWhitespace(this.parentNode.parentNode).childNodes[0].value=getObjInnerText(this);traverse(arcGsearch.thispageformfield.value, arcGsearch.gsearchxmlFileName, arcGsearch.dhtmlxTreeObj, arcGsearch.thispageformfield.id);arcGsearch.closeBox();'>"
								+ arrVal.split(",")[i] + "</a>";
					}
				}
			} else {
				if (arrVal.split(",")[i] != null
						|| arrVal.split(",")[i] != undefined) {
				 	var imgVla = "";
					 	imgVla = "<image src='images/measure.gif' border='0' align='ablmiddle'/>&nbsp;";
					if (arrVal.split(",")[i] != "") {
						hSr += "<a href='javascript:void(0);' class='srl' onclick='tempVal=getObjInnerText(this); tempVal=tempVal.split(\" [\"); finalVal = (tempVal[0]).substring(0,tempVal[0].length); if(finalVal==\"(Entity})\"){finalVal=\"{Entity}\"}; clickFlag = false; fillResultArea(document.getElementById(\"expressionsArea\"), \"\"+finalVal+\"\"); document.getElementById(\"expressionsArea\").focus();arcGsearch.closeBox();'>"
								+ imgVla + arrVal.split(",")[i] + "</a>";
					}
				}
			}
		}
		return hSr;
	},
	 closeBox:function(){
		this.$(this.getResultId).style.height = "120px";
		this.$(this.getResultId).style.zIndex = "9";
	 this.$(this.getResultId).innerHTML="";
		this.selNode = 0;
		this.$(this.getResultId).style.display = "none";
	},
	setGsearchFld : function(resultName, frmfldObj, xmlFlName, searchText,
			treeObj) {
		this.getResultId = resultName;
		this.thispageformfield = frmfldObj;
		this.dhtmlxTreeObj = treeObj;
		this.gsearchxmlFileName = xmlFlName;
		this.gsearchText = searchText;
		this.gsearchXmlDoc=getNewDOMInstance(this.gsearchxmlFileName);
		},
		setGsearchFldExp:function(resultName,frmfldObj){
		this.getResultId = resultName;
		this.thispageformfield = frmfldObj;
		},
	gsearchkeydown:function(e){
		var node=arcGsearch.$(arcGsearch.getResultId).childNodes;
		src=window.event?window.event.srcElement:e.target;
		var evt=window.event?window.event.keyCode:e.which;
		if (src.tagName == "A" && evt == 40 && node[arcGsearch.selNode]!=undefined ) {
			if(arcGsearch.selNode==node.length-1){
				node[node.length-1].className="srl";
				arcGsearch.selNode=0;
				arcGsearch.thispageformfield.focus();
			}
			else{
				node[arcGsearch.selNode].className="srl";
				arcGsearch.selNode+=1;
				if (BrowserDetect.browser=="Explorer")
					node[arcGsearch.selNode].focus();
				else
					node[arcGsearch.selNode-1].focus();
				node[arcGsearch.selNode].className="sr";
			}
		} else if (src.tagName=="A" && evt==38  && node[arcGsearch.selNode] != undefined) {
			if(arcGsearch.selNode==0){
				node[0].className="srl";
				arcGsearch.selNode=0;
				arcGsearch.thispageformfield.focus();
			}
			else{
				node[arcGsearch.selNode].className="srl";
				arcGsearch.selNode-=1;
				if (BrowserDetect.browser=="Explorer")
					node[arcGsearch.selNode].focus();
				else
					node[arcGsearch.selNode+1].focus();
				node[arcGsearch.selNode].className="sr";
			}
		}
		else if(src.tagName=="A" && evt==13){
					//FireFox fix innerHTML
					arcGsearch.thispageformfield.value=node[arcGsearch.selNode].innerHTML;
					arcGsearch.closeBox();
			if (arguments.length > 1 && arguments[1] == "searchString") {// for
																			// KPIbrowser
																			// listing
				arcGsearch.closeBox();
				searchKPIs("kpiBrowserListing", document
						.getElementById("searchString"),
						"tempKPIBrowserListing");
					}else
				traverse(arcGsearch.thispageformfield.value,
						arcGsearch.gsearchxmlFileName,
						arcGsearch.dhtmlxTreeObj,
						arcGsearch.thispageformfield.id);
				}
		return true;
	},
	gsearchkeydownExp:function(e){
		var node=arcGsearch.$(arcGsearch.getResultId).childNodes;
		src=window.event?window.event.srcElement:e.target;
		var evt=window.event?window.event.keyCode:e.which;
		if (src.tagName == "A" && evt == 40 && node[arcGsearch.selNode]!=undefined ) {
			if(arcGsearch.selNode==node.length-1){
				node[node.length-1].className="srl";
				arcGsearch.selNode=0;
				arcGsearch.thispageformfield.focus();
			}
			else{
				node[arcGsearch.selNode].className="srl";
				arcGsearch.selNode+=1;
				if (BrowserDetect.browser=="Explorer")
					node[arcGsearch.selNode].focus();
				else
					node[arcGsearch.selNode-1].focus();
				node[arcGsearch.selNode].className="sr";
			}
		} else if (src.tagName=="A" && evt==38  && node[arcGsearch.selNode] != undefined) {
			if(arcGsearch.selNode==0){
				node[0].className="srl";
				arcGsearch.selNode=0;
				arcGsearch.thispageformfield.focus();
				if (BrowserDetect.browser!="Explorer")
					arcGsearch.thispageformfield.selectionStart = setCursorPosForFF;
			}
			else{
				node[arcGsearch.selNode].className="srl";
				arcGsearch.selNode-=1;
				if (BrowserDetect.browser=="Explorer")
					node[arcGsearch.selNode].focus();
				else
					node[arcGsearch.selNode+1].focus();
				node[arcGsearch.selNode].className="sr";
			}
		}
		else if(src.tagName=="A" && evt==13){
			tempVal = getObjInnerText(node[arcGsearch.selNode]);
			tempVal = tempVal.split(" [");
			clickFlag = false;
			if (tempVal[0] == "{Entity}") {
				fillResultArea(arcGsearch.thispageformfield, tempVal[0]);
			} else {
				if (arguments.length > 1)
					fillResultArea(arcGsearch.thispageformfield, (tempVal[0]).substring(0,	tempVal[0].length), 'allMeas');
				else
					fillResultArea(arcGsearch.thispageformfield, (tempVal[0]).substring(0,	tempVal[0].length));
			}
			arcGsearch.closeBox();
			$("expressionsArea").focus();
		}
		return true;
	},
	gsearchCloseResult:function(divId){
	var divObj=null;
		if(this.$(divId) && this.$(divId).style.display=="block"){
			this.$(divId).style.zIndex="0";
			//this.$(divId).parentNode.childNodes[0].value="";
			this.$(divId).innerHTML="";
			this.$(divId).style.display="none";
			this.$(divId).style.height="0px";
}
for (i = 1; i < 10; i++) {
			   divObj=divId+i;
				if(this.$(divObj) && this.$(divObj).style.display=="block"){
					this.$(divObj).style.zIndex="0";
					//this.$(divObj).parentNode.childNodes[0].value="";
					this.$(divObj).innerHTML="";
					this.$(divObj).style.display="none";
					this.$(divObj).style.height="0px";
	}
}
return true;
}
	};
function initgSearch(ro,sb,xmlName,treeObj){
 arcGsearch.setGsearchFld(ro,document.getElementById(sb),xmlName,"text",treeObj);
}
function initgSearchExp(ro,sb){
 arcGsearch.setGsearchFldExp(ro,document.getElementById(sb));
 arcGsearch.gsearchCloseResult("resultText");
}

/* Search XML Ends*/
var newWin=null;
var newGetExcellReportWind=null;
function getExcellReport(){
	try{
		if(newGetExcellReportWind && window.open && !window.closed){
			window.focus();
			window.newGetExcellReportWind.close();
			newGetExcellReportWind=null;
			allWindows[allWindows.length-1]=null;
			newGetExcellReportWind=window.open("adminExportExcel","mywindow","toolbar=no,location=no,directories=no,menubar=yes,scrollbars=yes,resizable=yes,width=800,height=500,left=100,top=100");
			newGetExcellReportWind=window.open("adminExportExcel","mywindow","toolbar=no,location=no,directories=no,menubar=yes,scrollbars=yes,resizable=yes,width=800,height=500,left=100,top=100");
			allWindows[allWindows.length-1]=newGetExcellReportWind;
		}else{
		    if(allWindows[allWindows.length-1]!=null)
		    newGetExcellReportWind=window.open("adminExportExcel","mywindow","toolbar=no,location=no,directories=no,menubar=yes,scrollbars=yes,resizable=yes,width=800,height=500,left=100,top=100");
		    newGetExcellReportWind=window.open("adminExportExcel","mywindow","toolbar=no,location=no,directories=no,menubar=yes,scrollbars=yes,resizable=yes,width=800,height=500,left=100,top=100");
		    allWindows[allWindows.length]=newGetExcellReportWind;
		}
	}catch(err){
		alert(generalMsg[72]);
	}
}

function isSplChar(strObj){
		var str=strObj.value;
		var iChars = "!@#$%^*()+=[]\\\';/{}|\":<>?";
	  	for (var i = 0; i < str.length; i++) {
  			if (iChars.indexOf(str.charAt(i)) != -1) {
  				parent.document.getElementById('mandatorySection').innerHTML="<span class='contentRed'>Special characters are not allowed. Please try again.</span>";
  				//alert ("Special characters are not allowed.\n Please try again.");
				strObj.value="";strObj.focus();
  				return false;
  			}
  		}
  		return true;
	}
// added by Rasmit | Dt-10-july-2008
// method used in addalert.jsp and modifyalerts.jsp - for Grid functionalities
var tableDivInner="";
var tableDivInner1="";
function changeDhtmlGridPaging(pagingValue,tableDivName){
	document.getElementById("dataGrid2").innerHTML="";
  	document.getElementById("dataGrid1").innerHTML="";
	document.getElementById("dataGrid1").innerHTML=tableDivInner;
	document.getElementById("pagingArea").innerHTML="";
	document.getElementById("recinfoArea").innerHTML="";
	convertToDhtmlxGrid(tableDivName,pagingValue,"pagingArea","recinfoArea");
}
function changeDhtmlGridPaging1(pagingValue,tableDivName){
	document.getElementById("dataGrid1").innerHTML="";
  	document.getElementById("dataGrid2").innerHTML="";
	document.getElementById("dataGrid2").innerHTML=tableDivInner1;
	document.getElementById("pagingArea1").innerHTML="";
	document.getElementById("recinfoArea1").innerHTML="";
	convertToDhtmlxGrid(tableDivName,pagingValue,"pagingArea1","recinfoArea1");
}
function convertToDhtmlxGrid(tblId,pagingValue,pagingArea,reconfArea){
		if(document.getElementById(tblId)){
			var mygrid = new dhtmlXGridFromTable(tblId);
			mygrid.setImagePath("dhtmlX/codebaseGrid/imgs/");
			mygrid.setSkin("xp");
			mygrid.setColTypes("ra,ro");
			mygrid.setInitWidths("25,*");
			mygrid.enableAutoHeight(true,250,false);
			mygrid.enableAlterCss("tblRow1","tblRow2");
			document.getElementById(pagingArea).innerHTML="";
	 		document.getElementById(reconfArea).innerHTML="";
			mygrid.enablePaging(true,pagingValue,3,pagingArea,true,reconfArea);
			mygrid.setColSorting("na,str");
			mygrid.sortRows(1,"str","asc");
		}
	}

function selectAll(obj){
	var name = obj.name;
		if(obj.checked){
			if(obj.name == 'selectAllRole')
				checkAll('roleListing');
			if(obj.name == 'selectAllUser')
				checkAll('userListing');
		}else{
			if(obj.name == 'selectAllRole')
				uncheckAll('roleListing')
			if(obj.name == 'selectAllUser')
				uncheckAll('userListing');
		}
	}
function checkAll(listingObj){
	var list = document.getElementsByName(listingObj);
	var len = list.length;
	for(var i=0;i<len;i++){
		list[i].checked = true;
	}
}
function uncheckAll(listingObj){
	var list = document.getElementsByName(listingObj);
	var len = list.length;
	for(var i=0;i<len;i++){
		list[i].checked = false;
	}
}
function chkSelectAll(obj){
	if(obj.checked){
		obj.checked= false;
	}
	if(!obj.checked){
		return;
	}
}
function showAltHover(val, val1, evt){
	if(val1.indexOf(".gif")>0 || val1.indexOf(".jpg")>0 || val1.indexOf(".png")>0){
		val1="<div align=center>"+(val1.substr((val1.lastIndexOf("_")+1),val1.length))+"</div>";
	}

	if(null != document.getElementById('calloutContent') && document.getElementById('calloutContent')){
		document.getElementById('calloutContent').innerHTML=val1;
		if(document.getElementById('calloutContent').innerHTML!='' || document.getElementById('calloutContent').innerHTML!=null)
		{
			TagToTip('calloutContent', BALLOON, true, ABOVE, true, PADDING, 8, TEXTALIGN, 'justify', OFFSETX, -17);
		}
	}
}
function getOutlook(formName)
{
	invokePopup(generalMsg[47], "OutlookAddresses.jsp", "15,70", "350", "80");
}
/*func to Drag and drop Target enabling / hideing*/
function sunzDragTargetShow(val){}
function sunzDragTargetHide(){}
function highlightTarget(toHighlight, noHighlight){
	if(toHighlight!="")
	{
		toHighlight = toHighlight.split(",");
		for(i=0;i<toHighlight.length;i++)
		{
			if(toHighlight[i]=="dataGrid")
			{
				if(document.getElementById(toHighlight[i]))document.getElementById(toHighlight[i]).className="gridbox gridbox_red";
				if(document.getElementById(toHighlight[i])){if(document.getElementById(toHighlight[i]).childNodes[0]){document.getElementById(toHighlight[i]).childNodes[0].className="tblBgHightlightInner";}}
			}
			else
			if(toHighlight[i]=="level1")
			{
				if(document.getElementById(toHighlight[i]))document.getElementById(toHighlight[i]).className="tblBgHighlight";
				if(document.getElementById(toHighlight[i])){if(document.getElementById(toHighlight[i]).childNodes[0].childNodes[0].childNodes[0]){document.getElementById(toHighlight[i]).childNodes[0].childNodes[0].childNodes[0].className="dhx_tabbar_row tblBgHightlightInner";}}

			}
			else
			if(toHighlight[i]=="treeboxbox_treeFilter")
			{
				if(document.getElementById(toHighlight[i]))document.getElementById(toHighlight[i]).className="tblBgHighlight";
				if(document.getElementById(toHighlight[i])){if(document.getElementById(toHighlight[i]).childNodes[0]){document.getElementById(toHighlight[i]).childNodes[0].className="containerTableStyle tblBgHightlightInner";}}
			}
			else
			{
				if(document.getElementById(toHighlight[i]))document.getElementById(toHighlight[i]).className="tblBgHighlight";
				if(document.getElementById(toHighlight[i])){if(document.getElementById(toHighlight[i]).childNodes[0]){document.getElementById(toHighlight[i]).childNodes[0].className="tblBgHightlightInner";}}
			}
		}
	}
	if(noHighlight!="")	{
		noHighlight = noHighlight.split(",");
		for(i=0;i<noHighlight.length;i++)
		{
			if(noHighlight[i]=="dataGrid")
			{
				if(document.getElementById(noHighlight[i]))document.getElementById(noHighlight[i]).className="gridbox gridbox_light";
				if(document.getElementById(noHighlight[i])){if(document.getElementById(noHighlight[i]).childNodes[0]){document.getElementById(noHighlight[i]).childNodes[0].className="";}}
			}
			else
			if(noHighlight[i]=="level1")
			{
				if(document.getElementById(noHighlight[i]))document.getElementById(noHighlight[i]).className="";
				if(document.getElementById(noHighlight[i])){if(document.getElementById(noHighlight[i]).childNodes[0].childNodes[0].childNodes[0]){document.getElementById(noHighlight[i]).childNodes[0].childNodes[0].childNodes[0].className="dhx_tabbar_row";}}
			}
			else
			if(noHighlight[i]=="treeboxbox_treeFilter")
			{
				if(document.getElementById(noHighlight[i]))document.getElementById(noHighlight[i]).className="tblBorder";
				if(document.getElementById(noHighlight[i])){if(document.getElementById(noHighlight[i]).childNodes[0]){document.getElementById(noHighlight[i]).childNodes[0].className="containerTableStyle";}}
			}
			else
			{
				if(document.getElementById(noHighlight[i]))document.getElementById(noHighlight[i]).className="tblBorder";
				if(document.getElementById(noHighlight[i])){if(document.getElementById(noHighlight[i]).childNodes[0]){document.getElementById(noHighlight[i]).childNodes[0].className="";}}
			}
		}
	}
}
/*func to Drag and drop Target enabling / hideing ends*/
/*kpianalysis.jsp*/
function initialize(){
	if(historyStorage != null){
		var currentHistoryKey = historyStorage["currentHistoryKey"];
		var finalHistoryKey = historyStorage["finalHistoryKey"];
		if(currentHistoryKey == null){
			currentHistoryKey = '0';
			historyStorage["currentHistoryKey"] = currentHistoryKey;
			finalHistoryKey = '0';
			historyStorage["finalHistoryKey"] = finalHistoryKey;
		}
	}
}
function doHighLight(cpSideBarId){
	document.getElementById(cpSideBarId).style.background='#795c28';
}
function undoHighLight(cpSideBarId){
	document.getElementById(cpSideBarId).style.background='#cccccc';
}
var imageS = "";
function historySwapImage(imageId,imageSrc){
	imageS = document.getElementById(imageId).src;
	document.getElementById(imageId).src = imageSrc;
}
function historySwapImgRestore(imageId){
	document.getElementById(imageId).src = imageS;
}/*
function checkKeyCode(e){
	var key, node;
	if (e){
		key = e.which;
		node = e.target;
	}else{
		key = event.keyCode;
		node = event.srcElement;
	}
	 if(key == 116){
		if (e){
			e.which = 0;
			e.returnValue = false;
		}else{
			event.keyCode=0;
			event.returnValue = false;
		}
		return false
	}
	return true;
}*/
function checkUncheckAll(obj){
	if(obj.checked){
		checkAll('filterIds');
	}else if(!obj.checked){
		uncheckAll('filterIds');
	}
}
/*kpianalysis.jsp end*/
/*Function to Block F11 Key chitta modified*/
function fnBlock_F11(e) {
    var evtaltKey=window.event?event.altKey:e.altKey;
	var evtkeyCode=window.event?event.keyCode:e.which;
	var evtCtrlKey=window.event?event.ctrlKey:e.ctrlKey;
	var srcElmnt=window.event?event.srcElement:e.target;
	if (((evtkeyCode == 8) &&	(srcElmnt.type !=undefined && srcElmnt.type != "text" &&	srcElmnt.type != "textarea" &&
	srcElmnt.type != "password")) ||(evtCtrlKey && ((evtkeyCode == 82)) ) ||(evtkeyCode == 122)){
		try	{
			if(window.event)event.keyCode=0;
			else e.keyCode=0;
		}
		catch(err){}
		if(!enableBackSpace)
		{
			if(window.event)event.returnValue = false;
			else e.returnValue = false;
		}
	}
}
/*End of Function to Block F11 Key*/
function blockRightClick(){
	return false;

}
document.onkeydown= function(event)
{
	fnBlock_F11(event);
	checkKeycode(event);
}
//document.oncontextmenu = blockRightClick;
function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function getNoOfDaysInMonth(){
	var monthInfo=new Array(12);
	var getDateFeb=new Date();
	monthInfo[0]=31;//jan
	monthInfo[1]=daysInFebruary(getDateFeb.getFullYear());//feb
	monthInfo[2]=31;//march
	monthInfo[3]=30;//apr
	monthInfo[4]=31;//may
	monthInfo[5]=30;//june
	monthInfo[6]=31;//july
	monthInfo[7]=31;//aug
	monthInfo[8]=30;//sep
	monthInfo[9]=31;//oct
	monthInfo[10]=30;//nov
	monthInfo[11]=31;//dec
	return monthInfo[getDateFeb.getMonth()];
}
var kpiAnalysisGrid = false;
/* multiple sequencing*/
function moveOptionUp(obj){
	if(!hasOptions(obj)){
		return;
	}
	for(i=0;i<obj.options.length;i++){
		if(obj.options[i].selected){
			if(i != 0 && !obj.options[i-1].selected){
				swapOptionsMultiple(obj,i,i-1);
				obj.options[i-1].selected = true;
			}
		}
	}
}
function moveOptionDown(obj){
		if(!hasOptions(obj)){
			return;
		}
		for(i=obj.options.length-1;i>=0;i--){
			if(obj.options[i].selected){
				if(i !=(obj.options.length-1) && !obj.options[i+1].selected){
					swapOptionsMultiple(obj,i,i+1);
					obj.options[i+1].selected = true;
				}
			}
		}
	}
	function hasOptions(obj){
		if(obj!=null && obj.options!=null){
			return true;
		}
		return false;
	}
	function swapOptionsMultiple(obj,curPos,nextPos){
		var selObj = obj.options;
		var curPos_selected = selObj[curPos].selected;
		var nextPos_selected = selObj[nextPos].selected;
		var newNextPositionValue = new Option(selObj[curPos].text, selObj[curPos].value, selObj[curPos].defaultSelected, selObj[curPos].selected);
		var newCurrentPositionValue= new Option(selObj[nextPos].text, selObj[nextPos].value, selObj[nextPos].defaultSelected, selObj[nextPos].selected);
		selObj[nextPos] = newNextPositionValue;
		selObj[curPos] = newCurrentPositionValue;
		selObj[nextPos].selected = curPos_selected;
		selObj[curPos].selected = nextPos_selected;
	}
/* multiple sequencing ends*/
/*from trim.js*/
function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}
function ltrim(stringToTrim) {
	return stringToTrim.replace(/^\s+/,"");
}
function rtrim(stringToTrim) {
	return stringToTrim.replace(/\s+$/,"");
}
function trimWhiteSpacesInWord(stringToTrim){
	return stringToTrim.replace(/\s+/g," ");
}
/*from trim.js ends*/
/*session expire*/
function sessionExpire(){
	var xVal=window.screen.width - 10;
	var yVal=window.screen.height - 75;
	window.open('sessionTimeout.html','','top=0,left=0,height='+yVal+',width='+xVal+',status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes');
	if(parent){
		parent.close();
	}
	if(parent.window.opener){
		parent.window.opener.close();
	}
}
/*session expire ends*/
/* Function for Date picker*/
function clickIt(value){
	if (value != null &&  typeof(gfPop) != 'undefined'  &&  typeof(gfPop.fPopCalendar) != 'undefined'){
		gfPop.fPopCalendar(value);
	}
		return false;
}
function getMyDate(fmObj,STDate,EDDate){
	var objEDDate = document.getElementById(EDDate);
	//var objlastETlDate = document.getElementById('hdnToday');
	var objlastETlDate = document.getElementById('lastETlDate');
	if(document.getElementById('dimMaxDateFld')) objlastETlDate = document.getElementById('dimMaxDateFld');
	var objSTDate= document.getElementById(STDate);
	if(objSTDate.value != ''){
		var myETLArr=new Array(3);
		myETLArr[0]=objlastETlDate.value.split("-")[0];
		myETLArr[1]=objlastETlDate.value.split("-")[1];
		myETLArr[2]=objlastETlDate.value.split("-")[2];
		var myStartArr=new Array(3);
		myStartArr[0]=objSTDate.value.split("-")[0];
		myStartArr[1]=objSTDate.value.split("-")[1];
		myStartArr[2]=objSTDate.value.split("-")[2];
		// Support Issue 5431 Fix - Mohan, created date not working, the date field not allowing to select till the last etldate,
		if(objEDDate.value=='') {
			objEDDate.value = objlastETlDate.value;
		}
		//-------------
		gfPop.fPopCalendar(objEDDate,[[myStartArr[0],myStartArr[1],myStartArr[2]],[myETLArr[0],myETLArr[1],myETLArr[2]]], null);
		return false;
	}
	else{
		alert(generalMsg[48]);
		return false;
	}
}
function fnKPIAnalysisDate(fmObj,StartVal,objEndDate){
	var myEndDate = document.getElementById(objEndDate);
	var objStartVal = document.getElementById(StartVal);
	var objlastETlDate = document.getElementById('lastETlDate');
	// Support Issue 5431 Fix - Mohan, created date not working, the date field not allowing to select till the last etldate,
	if(objStartVal.value=='') {
		objStartVal.value = objlastETlDate.value ;
	}
	//----------------------
	if(myEndDate.value != '' && document.getElementById('layer9A') && document.getElementById('layer9A').style.display=='block')
	{
		var cfMsg = confirm(generalMsg[49]);
		if(cfMsg == true){
			myEndDate.value='';
			gfPop.fStartPop(objStartVal,objlastETlDate);
			return false;
		}
		else{
			document.getElementById('gToday:jsDateNormal_DFM:jsDateAgenda.js').style.visibility = "hidden";
		}
	}
	else{
		gfPop.fStartPop(objStartVal,objlastETlDate);
		return false;
		}
}
function getMyValidDate(fmObj,sourceFrom,StartVal,STDate,EDDate){
	var objStartVal = document.getElementById(StartVal);
	var objSTDate = document.getElementById(STDate);
	var objEDDate = document.getElementById(EDDate);
	var objhdnToday = document.getElementById('hdnToday');
	if(sourceFrom == 'ROP')
	{
		if(objStartVal.value != '')
		{
			gfPop.fEndPop(objSTDate,objEDDate);
			return false;
		}
		else
		{
			alert(generalMsg[50]);
			return false;
		}
	}
	else if(sourceFrom == 'ROPRange')
	{
		if(objStartVal.value != '')
		{
			var myHDNArr=new Array(3);
			myHDNArr[0]=parseInt(objhdnToday.value.split("-")[0]);
			myHDNArr[1]=parseInt(objhdnToday.value.split("-")[1]);
			myHDNArr[2]=parseInt(objhdnToday.value.split("-")[2]);

			var myStartArr=new Array(3);
			myStartArr[0]=objSTDate.value.split("-")[0];
			myStartArr[1]=objSTDate.value.split("-")[1];
			myStartArr[2]=objSTDate.value.split("-")[2];

			gfPop.fPopCalendar(objEDDate,[[myStartArr[0],myStartArr[1],myStartArr[2]],[myHDNArr[0],myHDNArr[1],myHDNArr[2]]], null);
			return false;
		}
		else
		{
			alert(generalMsg[48]);
			return false;
		}
	}
}

function fnClearDate(fmObj,StartVal,objEndDate,popMode){
	var myEndDate = document.getElementById(objEndDate);
	var objStartVal = document.getElementById(StartVal);
	var objhdnToday = document.getElementById('hdnToday');
	if(myEndDate.value != ''){
		var cfMsg = confirm(generalMsg[49]);
		if(cfMsg == true){
			myEndDate.value='';
			if(popMode == 'popStart'){
				gfPop.fStartPop(objStartVal,objhdnToday);
				return false;
				}
			else if(popMode == 'popStartNormal'){
				gfPop.fPopCalendar(objStartVal);
				return false;
			}
			else{
				gfPop.fEndPop(objhdnToday,objStartVal);
				return false;
				}
		}
		else{
			document.getElementById('gToday:jsDateNormal_DFM:jsDateAgenda.js').style.visibility = "hidden";
		}
	}
	else{
			if(popMode == 'popStart'){
				gfPop.fStartPop(objStartVal,objhdnToday);
				return false;
			}
			else if(popMode == 'popStartNormal'){
				gfPop.fPopCalendar(objStartVal);
				return false;
			}
			else{
				gfPop.fEndPop(objhdnToday,objStartVal);
				return false;
			}
		}
}
/* Function for Date picker ends*/
/* Security patch for recursive calling*/
function customTransfer(from,to,val1){
	var fromList = document.getElementById(from);
	var toList = document.getElementById(to);
	if (toList.options.length > 0 && toList.options[0].value == 'temp'){
		toList.options.length = 0;
	}
	if(val1.indexOf(":")>=0){
			for(i=0;i< val1.split(":").length-1;i++){
					toList.options[i] = new Option(val1.split(":")[i].trim(),val1.split(":")[i].trim());
			}
	}else{
			for (i=0;i<fromList.options.length;i++){
			var current = fromList.options[i];
			if (current.text==val1){
				txt = current.text;
				val = current.value;
				toList.options[toList.length] = new Option(txt,toList.length);
			}
		}
	}

	for(k=0;k<toList.options.length;k++){
		for (j=0;j< fromList.options.length;j++){
			if (toList.options[k].text==fromList.options[j].text){
				toList.options[k].value=fromList.options[j].value;
				fromList.remove(j);
			}
		}
	}
	fromList.selectedIndex='-1';
}
/* Security patch for recursive calling ends*/

/*get server time*/
	var currDateObj;
/*get server time ends*/
 function showSunZDiv(val)
 {
 	if(null != document.getElementById('calloutContent') && document.getElementById('calloutContent')){
		document.getElementById('calloutContent').innerHTML=val;
		if(document.getElementById('calloutContent').innerHTML!='' || document.getElementById('calloutContent').innerHTML!=null)
		{
			TagToTip('calloutContent', BALLOON, true, ABOVE, true, PADDING, 8, TEXTALIGN, 'justify', OFFSETX, -17);
		}
	}
 }


 /* to get val of selected radio*/
 function getRadioVal(parent,tag){
	var val;
	var someNodeList = $(parent).getElementsByTagName(tag);
	var nodes = $A(someNodeList);
	nodes.each(function(node){if(node.checked){val = node.value;}});
	return val;
}
/* to set dynamic Maxlength for textarea onPaste */
function imposeMaxLengthonPaste(Object,MaxLen){
	 if(Object.value.length >= MaxLen)
		 return false;
}
 /* to get val of selected radio - ends*/

/* to set dynamic Maxlength for textarea */
function imposeMaxLength(Object, MaxLen)
{
  return (Object.value.length <= MaxLen);
}
/* to set dynamic Maxlength for textarea -ends*/
/* to stop the user from entering non-numeric chars in numeric field*/
function Numeric_OnKeyPress(e){
	// e.keyCode - IE; e.which - Firefox
	var k = window.event ? event.keyCode : e.which;
	//k < 32  functions like 'refresh', 'backspace', 'delete' etc.
	// Only for Numbers
	if(k < 32 || k > 47 && k < 58)
	return true;
	else
	return false;
}
/*Numeric Validation Ends*/

// Added - Rasmit - date 09-Dec-2008
// CHECK THE KEY CODE OF .
function checkKeycode(event) {
	var keycode;
	if (window.event)
		keycode = window.event.keyCode;
	else
		keycode = event.which;

	if(!isKeyboardActive)
	{
		if(keycode == 116)
		{
			window.event.which = 0;
			window.event.keyCode = 0;
			window.event.returnValue = false;
			window.event.cancelBubble = true;
			e.stopPropagation();
		}
	}
}

// CHECK WHETHER THE FIRST DIGIT IS ZERO OR NOT

function checkZero(obj){
	if(obj != null && obj.value.length >0){
		var regularExpression  =  new RegExp("^[1-9]");
		if(! regularExpression.exec(obj.value)){
			return false;
		}
		else{
			return true;
		}
	}
}

// CHECK Month, Week, Days, Quarter range
function lastXPeriodRange(selDayObj, selRangeObj){
	var selDayVal = trim(selDayObj.value).toUpperCase();
	var rangeVal = trim(selRangeObj.value);

	if(selDayVal == 'QUARTERS'){
		if(rangeVal > 4){
			setValidationMessage(generalMsg[51]);
			selRangeObj.className = "inputFieldErr";
			return false;
		}
	}
	else if(selDayVal == 'MONTHS'){
		if(rangeVal > 12){
			setValidationMessage(generalMsg[52]);
			selRangeObj.className = "inputFieldErr";
			return false;
		}
	}
	else if(selDayVal == 'WEEKS'){
		if(rangeVal > 52){
			setValidationMessage(generalMsg[53]);
			selRangeObj.className = "inputFieldErr";
			return false;
		}
	}
	else if(selDayVal == 'DAYS'){
		if(rangeVal > 31){
			setValidationMessage(generalMsg[54]);
			selRangeObj.className = "inputFieldErr";
			return false;
		}
	}
	return true;
}
function hideNmFltrToolTip(toolTipPopId){
	if(globalTtipObj && document.getElementById(toolTipPopId))
		globalTtipObj.toolTip=document.getElementById(toolTipPopId).innerHTML;

	tt_OpReHref();
	if(tt_aV[DURATION] < 0 && (tt_iState & 0x2))
		tt_tDurt.Timer("tt_HideInit()", -tt_aV[DURATION], true);
	else if(!(tt_aV[STICKY] && (tt_iState & 0x2)))
		tt_HideInit();
}
function showNmFltrToolTip(toolTipPopId,e){
	 srcElmnt=window.event?event.srcElement:e.target;
	 if(srcElmnt.tagName=="SPAN" && srcElmnt.parentNode.parentNode.title!=""){
		 srcElmnt.parentNode.parentNode.setAttribute("toolTip",srcElmnt.parentNode.parentNode.title);
		 srcElmnt.parentNode.parentNode.title='';
	 }
	 var cleanedSRC = Element.cleanWhitespace(srcElmnt.parentNode.parentNode);
	 if(srcElmnt.tagName=="SPAN" && cleanedSRC.getAttribute('toolTip')!="" && cleanedSRC.getAttribute('toolTip')!="undefined"){
		 globalTtipObj=null;var objTitle=null;
  	     objTitle=cleanedSRC.getAttribute('toolTip');
		if(objTitle != null){
  	     //Added for Custom tooltip in Tree.
  	     objTitle = objTitle.replace('MName',"<span class='subHeadingSmall'>");
  	     objTitle = objTitle.replace('MForm',"</span>");
  	     objTitle = objTitle.replace('MIDForm',"</span><br/><b>");
  	     objTitle = objTitle.replace('MIDFormEnd',"</b>&nbsp;");
  	     objTitle = objTitle.replace('MID',"<span class='contentBlack'><b>");
  	     objTitle = objTitle.replace('MIDEND',"</b></span><br/><b>");
  	     objTitle = objTitle.replace('MFormEnd',"</b>&nbsp;");
 	     objTitle = objTitle.replace('Def',"<b>");
 	     objTitle = objTitle.replace('DefEnd',"</b>");
	     objTitle = objTitle.replace('&lt;',"<");
   	     objTitle = objTitle.replace('&gt;',">");
   	     objTitle = objTitle.replace('andlt;',"<");
   	     objTitle = objTitle.replace('andgt;',">");

  	     globalTtipObj=cleanedSRC;
		 objTitle=objTitle.replace("TRFG:-","<img src='images/icon_expression_green.gif' hspace=2 border='0' align=absmiddle/>");
		 objTitle=objTitle.replace("TRFY:-","<br/><img src='images/icon_expression_yellow.gif' hspace=2 border='0' align=absmiddle/>");
 		 objTitle=objTitle.replace("TRFR:-","<br/><img src='images/icon_expression_red.gif' border='0' hspace=2 align=absmiddle/>");
		 objTitle=objTitle.replace("TRNG:-","<img src='images/icon_trendline_arrowgreen.gif' hspace=2 border='0' align=absmiddle/>");
		 objTitle=objTitle.replace("TRNY:-","<br/><img src='images/icon_trendline_arrowyellow.gif' hspace=2 border='0' align=absmiddle/>");
		 objTitle=objTitle.replace("TRNR:-","<br/><img src='images/icon_trendline_arrowred.gif' border='0' hspace=2 align=absmiddle/>");
		 document.getElementById(toolTipPopId).innerHTML=objTitle;
		 if(document.getElementById(toolTipPopId).innerHTML!='' || document.getElementById(toolTipPopId).innerHTML!=null)
		 {
		 	TagToTip(toolTipPopId, BALLOON, true, ABOVE, true, PADDING, 10, TEXTALIGN, 'justify', OFFSETX, -10);
		 }
		}
	}
}
//planning submit and approve function
function getSubmitApprove(userId,planId,kpiId,templateId,viewId,taskId,versionId,subAppFlag,kpiName){
	var param1 = "&userId="+userId+"&planId="+planId+"&kpiId="+kpiId+"&templateId="+templateId+"&viewId="+viewId;
	var param2 = "&taskId="+taskId+"&versionId="+versionId+"&subAppFlag="+subAppFlag;
	var url = "arcplanning?nav_action=submitApproveAction"+param1+param2;
	var confMsg = confirm(generalMsg[55]+' '+subAppFlag+' '+ kpiName + ' ' + generalMsg[56]+': '+versionId+' '+generalMsg[57]);
	if(confMsg) {
		var myAjax = new Ajax.Request(url,
		{
			method: 'post',
			onComplete:function(orgreq){
				orgreq.responseText.evalScripts();
				kpiClick(viewId,'kpiLeftMenu'+viewId,'kpiClick');
				alert(orgreq.responseText);
			}
		});
	}
}
var _startTime = 0;
var totTime = 0;
var doonce = false;

var _myTimer = null;
var _myDelta = 50; // 50 milliseconds

function updateIt() {
  totTime = theDelta();
}

var inctl=0;
var TotalTime='';
var startedTimeLog = false;

function startIt() {
/*inctl=0;
startedTimeLog = true;
TotalTime ="";
  doonce =false;
  clearInterval(_myTimer);
  _startTime = new Date();
  _myTimer = setInterval("updateIt()",_myDelta);*/
}

function stopIt() {
	/*if(startedTimeLog)
	{
	  clearInterval(_myTimer);
	  totTime = theDelta();
	  TotalTime = TotalTime + ", " + totTime;
	  inctl=inctl+1;

	  if(inctl==6)
	  {
	  	inctl=0;
	  	alert("VALS: "+TotalTime);
	  	TotalTime="";
	    startedTimeLog=false;
	  }
	  doonce =true;
	 }*/
}

function theDelta() {
  var _tempTime = new Date();
  return (_tempTime.getTime() - _startTime.getTime());
}

function getMaximizeStatus(tblId){
	if($(tblId).style.display == 'block'){
		maximized = false;
	}
	else if($(tblId).style.display == 'none'){
		maximized = true;
	}
}
function validateMultiSelect(checkObj){
		var ctr=0;
		for(i=0;i<checkObj.length;i++){
			if(checkObj[i].checked == true ){
				ctr++;
			}
		}
		return ctr;
	}

function SetAllCheckBoxes(formObj)
{
	var formAndCheck = formObj.split("#");
	var FormName = formAndCheck[0];
	var FieldName = formAndCheck[1];
	var CheckValue;

	if(document.forms[FormName].g12.checked)
	{		CheckValue = true;	}
	else
	{		CheckValue = false;	}


	if(!document.forms[FormName])
	{		return;	}

	var objCheckBoxes = document.forms[FormName].elements[FieldName];
	if(!objCheckBoxes)
	{		return;	}

	var countCheckBoxes = objCheckBoxes.length;
	if(!countCheckBoxes)
	{		objCheckBoxes.checked = CheckValue;	}
	else
	{
		// set the check value for all check boxes
		for(var i = 0; i < countCheckBoxes; i++)
		{
			objCheckBoxes[i].checked = CheckValue;
			GetSelected(objCheckBoxes[i]);
		}

		document.getElementById("g12").checked = CheckValue;
	}
}

function GetSelected(objChk)
{

var objChkValue;
var objhdSelected;
objChkValue = objChk.value;
objhdSelected = document.getElementById('hdSelected').value;

if(objChk.checked)
{
	if(objhdSelected == "")
	{
		objhdSelected = objChkValue;
	}
	else
	{
		objhdSelected = objhdSelected + "," + objChkValue;
	}
}
else
{
	var valColl = objhdSelected.split(",");
	var strColl = 0;
	var resultString = "";
	var matchFound = false;
	for(strColl=0; strColl<valColl.length; strColl++)
	{
		if(valColl[strColl] != objChkValue)
		{
			matchFound = true;
			resultString += valColl[strColl] + ",";
		}
	}
	if(matchFound)
	resultString = resultString.substring(0,resultString.length-1);
	objhdSelected = resultString;
	}

	document.getElementById('hdSelected').value = objhdSelected;

	document.getElementById("g12").checked = false;
}

/*Global fix for tabbed browser*/
var gblNotRequired = true;
function gblTabFix()
{
	/*fix for custom tab items*/
	if(gblNotRequired)
	{
		tdVals = new Array();
		var allTdsForTab = document.getElementsByTagName("td");
		for(ttb1=0; ttb1<allTdsForTab.length; ttb1++)
		{
			if(allTdsForTab[ttb1].className=='customTabActive' || allTdsForTab[ttb1].className=='customTabInActive')
			{
				tdVals.push(allTdsForTab[ttb1].innerHTML);
				allTdsForTab[ttb1].innerHTML = '';
			}
		}

		for(ttb1=0; ttb1<allTdsForTab.length; ttb1++)
		{
			if(allTdsForTab[ttb1].className=='customTabActive' || allTdsForTab[ttb1].className=='customTabInActive')
			{
				allTdsForTab[ttb1].style.whiteSpace='nowrap';
				if(tdVals.length=='36')
				{
					if(BrowserDetect.browser=='Firefox'){
						allTdsForTab[ttb1].style.width='14%';
					}else{
					allTdsForTab[ttb1].style.width='16%';
				}
				}
				if(tdVals.length=='25')
				{
					if(BrowserDetect.browser=='Firefox'){
						allTdsForTab[ttb1].style.width='18%';
					}else{
					allTdsForTab[ttb1].style.width='20%';
				}
				}
				if(tdVals.length=='16')
				{
					if(BrowserDetect.browser=='Firefox'){
						allTdsForTab[ttb1].style.width='23%';
					}else{
					allTdsForTab[ttb1].style.width='25%';
				}
				}
				if(tdVals.length=='9')
				{
					if(BrowserDetect.browser=='Firefox'){
						allTdsForTab[ttb1].style.width='31%';
					}else{
					allTdsForTab[ttb1].style.width='33%';
				}
				}
				if(tdVals.length=='4')
				{
					if(BrowserDetect.browser=='Firefox'){
						allTdsForTab[ttb1].style.width='48%';
					}else{
					allTdsForTab[ttb1].style.width='50%';
				}
				}
				if(tdVals.length=='2')
				{
					allTdsForTab[ttb1].style.width='100%';
				}
			}
		}

		var getVal=-1;
		if(document.getElementById('dimensionBrowser'))document.getElementById('dimensionBrowser').style.display='block';
		for(ttb=0; ttb<allTdsForTab.length; ttb++)
		{
			if(allTdsForTab[ttb].className=='customTabActive' || allTdsForTab[ttb].className=='customTabInActive')
			{
				getVal= getVal +1;
				if(allTdsForTab[ttb].parentNode.parentNode.parentNode.style.display=='none')
				{
					allTdsForTab[ttb].parentNode.parentNode.parentNode.style.display='inline';
				}

				var truncateTextWidth = '';
				if(allTdsForTab[ttb].offsetWidth==0)
				{
					truncateTextWidth = 60;

				}
				else
				{
					if(BrowserDetect.browser=='Firefox'){
						truncateTextWidth = (allTdsForTab[ttb].offsetWidth - 10);
					}else{
						truncateTextWidth = allTdsForTab[ttb].offsetWidth;
					}
				}
				if(BrowserDetect.browser=='Firefox'){
						//allTdsForTab[ttb].innerHTML = "<div class='truncateText' style='float:left;width:"+truncateTextWidth+"px !important'>&nbsp;"+tdVals[getVal]+"</div><div style='float:left' id='spnTruncate'></div>";
						var myValue = autoEllipseText(allTdsForTab[ttb],tdVals[getVal].replace(/&nbsp;/g,''),truncateTextWidth);
						allTdsForTab[ttb].innerHTML = "<div style='width:"+truncateTextWidth+"px !important'>&nbsp;"+myValue+"</div>";
						//allTdsForTab[ttb].title = allTdsForTab[ttb].childNodes[0].childNodes[2].nodeValue;
						allTdsForTab[ttb].title = tdVals[getVal].split(">&nbsp;")[1];
				}else{
						allTdsForTab[ttb].innerHTML = "<div class='truncateText' style='width:"+truncateTextWidth+"px !important'>&nbsp;"+tdVals[getVal]+"</div>";
						allTdsForTab[ttb].title = allTdsForTab[ttb].innerText;
				}



				if(allTdsForTab[ttb].parentNode.parentNode.parentNode.style.display=='inline')
				{
					allTdsForTab[ttb].parentNode.parentNode.parentNode.style.display='none';
				}
			}

			if(allTdsForTab[ttb].className=='customTabActiveBrd' || allTdsForTab[ttb].className=='customTabInActiveBrd' || allTdsForTab[ttb].className=='customTabActiveInActiveBrd')
			{
				if(BrowserDetect.browser!='Firefox'){
				allTdsForTab[ttb].innerHTML = "<img src='../images/spacer.gif' height='1' width='10'/>";
			}
		}
		}
		if(document.getElementById('dimensionBrowser'))document.getElementById('dimensionBrowser').style.display='none';
	}
	/*fix for custom tab items*/

	/*fix for top items & admin menu items*/
	var allTdsForTab = document.getElementsByTagName("div");

	var totalTopIconDivs = 0;
	for(ttbDiv=0; ttbDiv<allTdsForTab.length; ttbDiv++)
	{
		if(allTdsForTab[ttbDiv].className=='topIcons' || allTdsForTab[ttbDiv].className=='topIconsActive' || allTdsForTab[ttbDiv].className=='topIcons imgDisabled')
		{
			totalTopIconDivs++;
		}
	}

	var autowidth = 75;

	if(screen.width==1024)
	{
		if(totalTopIconDivs<=8)
			autowidth = "auto";
		if(totalTopIconDivs>8 && totalTopIconDivs<=9)
			autowidth = 85 +"px";
		if(totalTopIconDivs>9 && totalTopIconDivs<=10)
			autowidth = 74 +"px";
		if(totalTopIconDivs>10 && totalTopIconDivs<=11)
			autowidth = 66 +"px";
		if(totalTopIconDivs>11 && totalTopIconDivs<=12)
			autowidth = 59 +"px";
		if(totalTopIconDivs>12 && totalTopIconDivs<=13)
			autowidth = 52 +"px";
		if(totalTopIconDivs>13 && totalTopIconDivs<=14)
			autowidth = 47 +"px";
		if(totalTopIconDivs>14 && totalTopIconDivs<=16)
			autowidth = 42 +"px";
	}
	if(screen.width==1280)
	{
		if(totalTopIconDivs<=9)
			autowidth = "auto";
		if(totalTopIconDivs>9 && totalTopIconDivs<=10)
			autowidth = "auto";
		if(totalTopIconDivs>10 && totalTopIconDivs<=11)
			autowidth = 89 +"px";
		if(totalTopIconDivs>11 && totalTopIconDivs<=12)
			autowidth = 79 +"px";
		if(totalTopIconDivs>12 && totalTopIconDivs<=13)
			autowidth = 71 +"px";
		if(totalTopIconDivs>13 && totalTopIconDivs<=14)
			autowidth = 64 +"px";
		if(totalTopIconDivs>14 && totalTopIconDivs<=16)
			autowidth = 59 +"px";
	}
	if(screen.width==1440)
	{
		if(totalTopIconDivs<=9)
			autowidth = "auto";
		if(totalTopIconDivs>9 && totalTopIconDivs<=10)
			autowidth = "auto";
		if(totalTopIconDivs>10 && totalTopIconDivs<=11)
			autowidth = "auto";
		if(totalTopIconDivs>11 && totalTopIconDivs<=12)
			autowidth = "auto";
		if(totalTopIconDivs>12 && totalTopIconDivs<=13)
			autowidth = 84 +"px";
		if(totalTopIconDivs>13 && totalTopIconDivs<=14)
			autowidth = 76 +"px";
		if(totalTopIconDivs>14 && totalTopIconDivs<=16)
			autowidth = 69 +"px";
	}

	for(ttb=0; ttb<allTdsForTab.length; ttb++)
	{
		if(allTdsForTab[ttb].className=='topIcons' || allTdsForTab[ttb].className=='topIconsActive')
		{
			if(allTdsForTab[ttb].parentNode.offsetHeight>=50)
			{
				allTdsForTab[ttb].innerHTML = "<div class='truncateText' style='width:"+autowidth+" !important'>"+allTdsForTab[ttb].innerHTML+"</div>";
				allTdsForTab[ttb].title = trim(allTdsForTab[ttb].innerText);
			}
		}

		if(allTdsForTab[ttb].className=='topIcons imgDisabled')
		{
			if(allTdsForTab[ttb].parentNode.offsetHeight>=50)
			{
				allTdsForTab[ttb].innerHTML = "<div class='truncateText' style='width:"+autowidth+" !important'>"+allTdsForTab[ttb].innerHTML+"</div>";
				allTdsForTab[ttb].title = trim(allTdsForTab[ttb].innerText);
			}
		}

		if(allTdsForTab[ttb].className=='admenuBarLeft' || allTdsForTab[ttb].className=='admenuBarLeftHigh')
		{
			allTdsForTab[ttb].whiteSpace = 'noWrap';
			if(allTdsForTab[ttb].parentNode.parentNode.offsetHeight>=40)
			{
				allTdsForTab[ttb].innerHTML = "<div class='truncateText' style='width:60px !important'>"+allTdsForTab[ttb].innerHTML+"</div>";
				allTdsForTab[ttb].title = trim(allTdsForTab[ttb].innerText);
			}
		}
	}
	/*fix for top items & admin menu items*/
}

/*Global fix for tabbed browser*/

/* Added by Manoj babu for displaying Full text in Header */
function showFullText(obj){
	var curleft = 0;
	var curtop = 0;
	var objdisplayContent = document.getElementById('divDisplayContent');
	objdisplayContent.style.display ='block';
	objdisplayContent.innerHTML = obj.innerHTML;
	objdisplayContent.onclick = obj.onclick;
	//setTimeout("clearFullText(); clearTimeout(timerPopup)", "1000");
	if (obj.offsetParent) {
				do {
					curleft += obj.offsetLeft;
					curtop += obj.offsetTop;
					} while (obj = obj.offsetParent);
				}
		 else if (obj.x){
				 curtop += obj.y;
				 curleft += obj.x;
				}
	if(navigator.userAgent.indexOf("MSIE")>0)
	{
		objdisplayContent.style.left=curleft;
		objdisplayContent.style.top=curtop;
	}
	else{ // for Firefox
		objdisplayContent.style.top = curtop -4 + "px";
		objdisplayContent.style.left = curleft -1 + "px";
	}
}
function clearFullText(){
	var objdisplayContent = document.getElementById('divDisplayContent');
	objdisplayContent.style.display ='none';
	objdisplayContent.innerHTML = "";

}
/*End of displaying full Text*/


/*added by Murali for checkbox*/
function setChkBx(chbxObj){
	if(! chbxObj.checked){
		chbxObj.checked = false;
		document.getElementById('g12').checked=false;
	}
	else{
		chbxObj.checked = true;
	}
}
/*added by Murali for checkbox*/

/*** Muthu - 27-03-09 ***/
function executeQuestion(selId){
   var url = "arcui?nav_action=QUESTIONSACTION&action=executeQuestion&selId="+selId;
   var myAjax = new Ajax.Request(url,{
		method: 'post',
		onComplete: function(response){
			alert(response.responseText);
			window.location.reload(true);
		}
	});
}


function createrLoaderDiv()
{
	//if(!parent.document.getElementById('winLoader'))
	//{//alert("created");
		//if(parent.document.getElementById('winLoader')){parent.document.body.removeChild(parent.document.getElementById('winLoader'));}
		//if(document.getElementById('winLoader')){document.body.removeChild(document.getElementById('winLoader'));}
		//addContentToPage = "<div id='winLoader' style='position:absolute;z-index:10000; top:"+window.screen.height/2+"px; left:"+window.screen.width/2+"px; display:block; background-image:url(images/newLoader.gif); background-repeat:no-repeat; background-position:12px 12px; width:30px; height:30px;'></div>"
		addContentToPage = "<div id='winLoader' style='position:absolute;z-index:10000; top:"+window.screen.height/2+"px; left:"+window.screen.width/2+"px; display:block; background-image:url(images/newLoader.gif); background-repeat:no-repeat; background-position:12px 12px; width:30px; height:30px; margin:10px 0px 0px 10px; *margin:0px'></div>"
		document.writeln(addContentToPage);
	//}
}
var allModClicks = "";
var smallPopupEventArray = new Array();
function closeLoaderDiv()
{
	allAhref = document.getElementsByTagName('a');
	var newIncrementor = 0;
	for(i=0;i<allAhref.length;i++)
	{
		if(allAhref[i].attributes["onclick"])
		{
			if((allAhref[i].attributes["onclick"].value).substring(0,11) == 'swapFilters')
			{
				newIncrementor++;
				newVal = allAhref[i].innerHTML;
				allAhref[i].innerHTML= '<div id="coverUpDiv_treeUtil'+newIncrementor+'" style="display:none; position:absolute; background-color:#ffffff; opacity:0.7; filter:alpha(opacity=70); height:45px; z-index:9999999; margin-left:-10px; font-size:20px; width:200px; color:#666666">&nbsp;Loading...<br/><img src="images/kpiLoader.gif" border="0" width="200" height="19"/></div><span style="color:#000000; cursor:default">'+newVal+'</span>';
			}
		}
	}

	if(document.getElementById('menuTop'))
	{
		var allBoardKeyItems = '';
		var keyCharNumVal = 1;
		var append=0;
		Element.cleanWhitespace(document.getElementById('menuTop'));
		var allModules = document.getElementById('menuTop');
		for(i=0; i<allModules.childNodes.length-1; i++)
		{
			boardKeyItem = (allModules.childNodes[i].childNodes[0].innerHTML).substring(0,1).toUpperCase();
			allBoardKeyItems = allBoardKeyItems + "," + (allModules.childNodes[i].childNodes[0].innerHTML).substring(0,1).toUpperCase();

			for(n=0; n<allBoardKeyItems.split(',').length; n++)
			{
				if(allBoardKeyItems.split(',')[n]==boardKeyItem)
				{
					append++;
				}
			}
			if(append>=2){
				if(BrowserDetect.OS=='Mac' && BrowserDetect.browser=='Firefox'){
					boardKeyItemAdd = "Meta+"+keyCharNumVal;
				}else{
					boardKeyItemAdd = "Alt+"+keyCharNumVal;
				}
				keyCharNumVal++;
			}
			else{
				if(BrowserDetect.OS=='Mac' && BrowserDetect.browser=='Firefox'){
					boardKeyItemAdd = "Meta+"+boardKeyItem;
				}else{
					boardKeyItemAdd = "Alt+"+boardKeyItem;
				}
			}
			var appender="";
			var appender1="";
			if(i%2==0)
			{
				appender ="<img src='images/spacer.gif' height='15' width='10'/><br/>";
			}
			if(document.getElementById('addShortCuts')) document.getElementById('addShortCuts').innerHTML= document.getElementById('addShortCuts').innerHTML + "<div style='width:150px; float:left;'>"+ allModules.childNodes[i].childNodes[0].innerHTML+": "+boardKeyItemAdd + "</div>" + appender;
			if(allModClicks=="")
			{
				allModClicks = "assignModuleGroupKPI('"+allModules.childNodes[i].getAttribute("modGrpKpi")+"');moduleClick('"+allModules.childNodes[i].getAttribute("viewID")+"','"+allModules.childNodes[i].getAttribute("id")+"','1','moduleClick')";
			}
			else
			{
				allModClicks = allModClicks + "#" + "assignModuleGroupKPI('"+allModules.childNodes[i].getAttribute("modGrpKpi")+"');moduleClick('"+allModules.childNodes[i].getAttribute("viewID")+"','"+allModules.childNodes[i].getAttribute("id")+"','1','moduleClick')";
			}
			append=0;
		}

		keyCharNumVal = 1;
		allBoardKeyItems='';

		allModClicks = allModClicks.split("#");
			for(i=0; i<allModules.childNodes.length-1; i++)
			{
				boardKeyItem = (allModules.childNodes[i].childNodes[0].innerHTML).substring(0,1).toUpperCase();
				allBoardKeyItems = allBoardKeyItems + "," + (allModules.childNodes[i].childNodes[0].innerHTML).substring(0,1).toUpperCase();

				for(n=0; n<allBoardKeyItems.split(',').length; n++)
				{
					if(allBoardKeyItems.split(',')[n]==boardKeyItem)
					{
						append++;
					}
				}
				if(append>=2){
					if(BrowserDetect.OS=='Mac' && BrowserDetect.browser=='Firefox'){
						boardKeyItemAdd = "Meta+"+keyCharNumVal;
					}else{
						boardKeyItemAdd = "Alt+"+keyCharNumVal;
					}
					keyCharNumVal++;
				}
				else{
					if(BrowserDetect.OS=='Mac' && BrowserDetect.browser=='Firefox'){
						boardKeyItemAdd = "Meta+"+boardKeyItem;
					}else{
						boardKeyItemAdd = "Alt+"+boardKeyItem;
					}
				}

				if(isKeyboardActive)
				{
					if(i==0){shortcut.add(boardKeyItemAdd,function(){eval(allModClicks[0]);});}
					if(i==1){shortcut.add(boardKeyItemAdd,function(){eval(allModClicks[1]);});}
					if(i==2){shortcut.add(boardKeyItemAdd,function(){eval(allModClicks[2]);});}
					if(i==3){shortcut.add(boardKeyItemAdd,function(){eval(allModClicks[3]);});}
					if(i==4){shortcut.add(boardKeyItemAdd,function(){eval(allModClicks[4]);});}
					if(i==5){shortcut.add(boardKeyItemAdd,function(){eval(allModClicks[5]);});}
					if(i==6){shortcut.add(boardKeyItemAdd,function(){eval(allModClicks[6]);});}
					if(i==7){shortcut.add(boardKeyItemAdd,function(){eval(allModClicks[7]);});}
					if(i==8){shortcut.add(boardKeyItemAdd,function(){eval(allModClicks[8]);});}
					if(i==9){shortcut.add(boardKeyItemAdd,function(){eval(allModClicks[9]);});}
					if(i==10){shortcut.add(boardKeyItemAdd,function(){eval(allModClicks[10]);});}
					if(i==11){shortcut.add(boardKeyItemAdd,function(){eval(allModClicks[11]);});}
					if(i==12){shortcut.add(boardKeyItemAdd,function(){eval(allModClicks[12]);});}
					if(i==13){shortcut.add(boardKeyItemAdd,function(){eval(allModClicks[13]);});}
					if(i==14){shortcut.add(boardKeyItemAdd,function(){eval(allModClicks[14]);});}
					if(i==15){shortcut.add(boardKeyItemAdd,function(){eval(allModClicks[15]);});}
					if(i==16){shortcut.add(boardKeyItemAdd,function(){eval(allModClicks[16]);});}
					if(i==17){shortcut.add(boardKeyItemAdd,function(){eval(allModClicks[17]);});}
					if(i==18){shortcut.add(boardKeyItemAdd,function(){eval(allModClicks[18]);});}
					if(i==19){shortcut.add(boardKeyItemAdd,function(){eval(allModClicks[19]);});}
				}
				append=0;
			}
	}
//	alert("isKeyboardActive: "+isKeyboardActive +".");
	if(isKeyboardActive)
	{
		if(document.getElementById('keybrdOff') && document.getElementById('keybrdOn'))
		{
			document.getElementById('keybrdOff').style.display='none';
			document.getElementById('keybrdOn').style.display='block';
		}

		shortcut.add("Ctrl+A",function() {
			if(document.getElementById('filterSectionButton'))
			{
				startIt();
				ValidateFormsClickButton();
			}
		});

		shortcut.add("Ctrl+L",function() {
			if(document.getElementById('toputi_1_globalLinks') || document.getElementById('topBarRight_M'))
			{
				logOut('login.jsp');
			}
			if(document.getElementById('loginButton'))
			{
				if(document.getElementById('rememberKey').checked){rememberMe()}else{dontRememberMe()}; if(document.getElementById('rememberKeyPass').checked){rememberMePass()}else{dontRememberMePass()}; Submit();
			}
		});

		shortcut.add("Ctrl+S",function() {
			if(document.getElementById('toputi_1_browserLinks'))
			{
				stopDBProcess();
			}
			if(document.getElementById('topBarRight_M'))
			{
				adminStop();
			}
		});

		shortcut.add("Ctrl+R",function() {
			if(document.getElementById('toputi_1_browserLinks'))
			{
				ajaxHistoryRefresh();
			}
			if(BrowserDetect.OS!='Mac'){
				if(document.getElementById('topBarRight_M'))
				{
					location.reload(true);
				}
			}
		});

		shortcut.add("Ctrl+<",function() {
			if(document.getElementById('toputi_1_browserLinks'))
			{
				ajaxHistoryBack();
			}
			if(document.getElementById('topBarRight_M'))
			{
				history.back();
			}
		});

		shortcut.add("Ctrl+>",function() {
			if(document.getElementById('toputi_1_browserLinks'))
			{
				ajaxHistoryForward();
			}
			if(document.getElementById('topBarRight_M'))
			{
				history.forward();
			}
		});

		shortcut.add("Ctrl+K",function() {
			if(document.getElementById('KPIBrowser'))
			{
				document.getElementById('viewsKPIBrowser').checked=false;
				showHidePanel('KPIBrowser', 'portletLeft', 'kpiCenter_ShowHide');
			}
		});

		shortcut.add("Ctrl+B",function() {
			if(document.getElementById('KPIBrowser'))
			{
				showHidePanelLayer('dimensionBrowser')
			}
		});

		shortcut.add("Ctrl+D",function() {
			if(document.getElementById('dockDivId'))
			{
				dockPortlet('dataGridContainer', document.getElementById('dockDivId'));
			}
		});
	}
	else
	{
		if(document.getElementById('keybrdOff') && document.getElementById('keybrdOn'))
		{
			document.getElementById('keybrdOff').style.display='block';
			document.getElementById('keybrdOn').style.display='none';
		}
	}
	//alert("removed");
	if(document.getElementById('winLoader'))document.getElementById('winLoader').style.display='none';
	if(parent.document.getElementById('winLoader'))parent.document.getElementById('winLoader').style.display='none';

	//Admin Menulist Close on click of any admin page
	if(document.getElementById('adutilityBarPopup')){document.onclick =function(){if(hideFlag==true)document.getElementById('adutilityBarPopup').style.display='none'};}
	if(parent.document.getElementById('adutilityBarPopup')){document.onclick =function(){if(hideFlag==true)parent.document.getElementById('adutilityBarPopup').style.display='none'};}
	if(parent.parent.document.getElementById('adutilityBarPopup')){document.onclick =function(){if(hideFlag==true)parent.parent.document.getElementById('adutilityBarPopup').style.display='none'};}
	if(parent.parent.parent.document.getElementById('adutilityBarPopup')){document.onclick =function(){if(hideFlag==true)parent.parent.parent.document.getElementById('adutilityBarPopup').style.display='none'};}
}

function attachEventToExpandSmallPopup()
{
	getAllSmallPopUps = document.getElementsByTagName("div");

	for(i=0; i<getAllSmallPopUps.length; i++)
	{
		if(getAllSmallPopUps[i].className=="toolBar" && getAllSmallPopUps[i].style.display == "block")
		{
			if(getAllSmallPopUps[i].getElementsByTagName("table").length>0)
			{
				getAllSmallPopUps[i].style.width = getAllSmallPopUps[i].getElementsByTagName("table")[0].offsetWidth+20;
				newLeftWidth = document.documentElement.scrollWidth - document.body.clientWidth;
				getAllSmallPopUps[i].style.left = getAllSmallPopUps[i].offsetLeft - newLeftWidth;

			}
		}
	}
}

createrLoaderDiv();

var checkInt = setInterval('if(document.body){if(window.onload){addOnLoad(yourOnLoad)}else{yourOnLoad()}}', '1000');
function addOnLoad(nextOnLoad) {
	clearInterval(checkInt);
    eval("nextOnLoad()");
}

function yourOnLoad()
{
	if(checkInt)clearInterval(checkInt);
	closeLoaderDiv();
}

/*key board shortcuts include*/
shortcut = {
	'all_shortcuts':{},//All the shortcuts are stored in this array
	'add': function(shortcut_combination,callback,opt) {
		//Provide a set of default options
		var default_options = {
			'type':'keydown',
			'propagate':false,
			'disable_in_input':false,
			'target':document,
			'keycode':false
		}

		if(!opt) opt = default_options;
		else {
			for(var dfo in default_options) {
				if(typeof opt[dfo] == 'undefined') opt[dfo] = default_options[dfo];
			}
		}

		var ele = opt.target;
		if(typeof opt.target == 'string') ele = document.getElementById(opt.target);
		var ths = this;
		shortcut_combination = shortcut_combination.toLowerCase();

		//The function to be called at keypress
		var func = function(e) {
			e = e || window.event;

			if(opt['disable_in_input']) { //Don't enable shortcut keys in Input, Textarea fields
				var element;
				if(e.target) element=e.target;
				else if(e.srcElement) element=e.srcElement;
				if(element.nodeType==3) element=element.parentNode;

				if(element.tagName == 'INPUT' || element.tagName == 'TEXTAREA') return;
			}

			//Find Which key is pressed
			if (e.keyCode) code = e.keyCode;
			else if (e.which) code = e.which;
			var character = String.fromCharCode(code).toLowerCase();
			if(code == 116){event.keyCode = 0;event.returnValue = false;}
			if(code == 188) character=","; //If the user presses , when the type is onkeydown
			if(code == 190) character="."; //If the user presses , when the type is onkeydown

			var keys = shortcut_combination.split("+");
			//Key Pressed - counts the number of valid keypresses - if it is same as the number of keys, the shortcut function is invoked
			var kp = 0;

			//Work around for stupid Shift key bug created by using lowercase - as a result the shift+num combination was broken
			var shift_nums = {
				"`":"~",
				"1":"!",
				"2":"@",
				"3":"#",
				"4":"$",
				"5":"%",
				"6":"^",
				"7":"&",
				"8":"*",
				"9":"(",
				"0":")",
				"-":"_",
				"=":"+",
				";":":",
				"'":"\"",
				",":"<",
				".":">",
				"/":"?",
				"\\":"|"
			}
			//Special Keys - and their codes
			var special_keys = {
				'esc':27,
				'escape':27,
				'tab':9,
				'space':32,
				'return':13,
				'enter':13,
				'backspace':8,

				'scrolllock':145,
				'scroll_lock':145,
				'scroll':145,
				'capslock':20,
				'caps_lock':20,
				'caps':20,
				'numlock':144,
				'num_lock':144,
				'num':144,

				'pause':19,
				'break':19,

				'insert':45,
				'home':36,
				'delete':46,
				'end':35,

				'pageup':33,
				'page_up':33,
				'pu':33,

				'pagedown':34,
				'page_down':34,
				'pd':34,

				'left':37,
				'up':38,
				'right':39,
				'down':40,

				'f1':112,
				'f2':113,
				'f3':114,
				'f4':115,
				'f5':116,
				'f6':117,
				'f7':118,
				'f8':119,
				'f9':120,
				'f10':121,
				'f11':122,
				'f12':123
			}

			var modifiers = {
				shift: { wanted:false, pressed:false},
				ctrl : { wanted:false, pressed:false},
				alt  : { wanted:false, pressed:false},
				meta : { wanted:false, pressed:false}	//Meta is Mac specific
			};

			if(e.ctrlKey)	modifiers.ctrl.pressed = true;
			if(e.shiftKey)	modifiers.shift.pressed = true;
			if(e.altKey)	modifiers.alt.pressed = true;
			if(e.metaKey)   modifiers.meta.pressed = true;

			for(var i=0; k=keys[i],i<keys.length; i++) {
				//Modifiers
				if(k == 'ctrl' || k == 'control') {
					kp++;
					modifiers.ctrl.wanted = true;

				} else if(k == 'shift') {
					kp++;
					modifiers.shift.wanted = true;

				} else if(k == 'alt') {
					kp++;
					modifiers.alt.wanted = true;
				} else if(k == 'meta') {
					kp++;
					modifiers.meta.wanted = true;
				} else if(k.length > 1) { //If it is a special key
					if(special_keys[k] == code) kp++;

				} else if(opt['keycode']) {
					if(opt['keycode'] == code) kp++;

				} else { //The special keys did not match
					if(character == k) kp++;
					else {
						if(shift_nums[character] && e.shiftKey) { //Stupid Shift key bug created by using lowercase
							character = shift_nums[character];
							if(character == k) kp++;
						}
					}
				}
			}

			if(kp == keys.length &&
						modifiers.ctrl.pressed == modifiers.ctrl.wanted &&
						modifiers.shift.pressed == modifiers.shift.wanted &&
						modifiers.alt.pressed == modifiers.alt.wanted &&
						modifiers.meta.pressed == modifiers.meta.wanted) {
				callback(e);

				if(!opt['propagate']) { //Stop the event
					//e.cancelBubble is supported by IE - this will kill the bubbling process.
					e.cancelBubble = true;
					e.returnValue = false;

					//e.stopPropagation works in Firefox.
					if (e.stopPropagation) {
						e.stopPropagation();
						e.preventDefault();
					}
					return false;
				}
			}
		}
		this.all_shortcuts[shortcut_combination] = {
			'callback':func,
			'target':ele,
			'event': opt['type']
		};
		//Attach the function with the event
		if(ele.addEventListener) ele.addEventListener(opt['type'], func, false);
		else if(ele.attachEvent) ele.attachEvent('on'+opt['type'], func);
		else ele['on'+opt['type']] = func;
	},

	//Remove the shortcut - just specify the shortcut and I will remove the binding
	'remove':function(shortcut_combination) {
		shortcut_combination = shortcut_combination.toLowerCase();
		var binding = this.all_shortcuts[shortcut_combination];
		delete(this.all_shortcuts[shortcut_combination])
		if(!binding) return;
		var type = binding['event'];
		var ele = binding['target'];
		var callback = binding['callback'];

		if(ele.detachEvent) ele.detachEvent('on'+type, callback);
		else if(ele.removeEventListener) ele.removeEventListener(type, callback, false);
		else ele['on'+type] = false;
	}
}
/*key board shortcuts include ends*/

/* Generic method to add from list to another list objects but its not remove from first listbox */
function addOnlyOptions(fromList,toList){
	if (fromList == null) return;
	if (toList == null) return;
	toList.innerHTML = "";

	for (i=0;i<fromList.options.length;i++)
	{
		var current = fromList.options[i];
		txt = current.text;
		val = current.value;
		toList.options[toList.length] = new Option(txt,val);
	}
}

/* Generic method to remove selected options from the given list box */
function removeSelectedOptions(from){
		var fromList = document.getElementById(from);
		var i;
	  	for (i = fromList.length - 1; i>=0; i--) {
	    	if (fromList.options[i].selected) {
      			fromList.remove(i);
		    }
  		}
	}

//Layoutset code starts -- Author : Manoj & Ramprasad
function setKPILayout(strLayoutID,strTemplateOrder){
	var poMargin ="";
	if(strLayoutID=='1' && (strTemplateOrder=='3_1_2' || strTemplateOrder=='3_2_1')){
		poMargin="0px 0px 3px 0px";
	}else if(strLayoutID=='2' && (strTemplateOrder=='3_1_2' || strTemplateOrder=='3_2_1' || strTemplateOrder=='1_3_2' || strTemplateOrder=='2_3_1')){
		poMargin="0px 0px 3px 0px";
	}else if(strLayoutID=='3' && (strTemplateOrder=='1_2_3' || strTemplateOrder=='3_1_2' || strTemplateOrder=='3_2_1' || strTemplateOrder=='1_3_2' || strTemplateOrder=='2_3_1')){
		poMargin="0px 0px 3px 0px";
	}else{
		poMargin="10px 0px 3px 0px";
	}
	var filtersBox = "<div id='filtersPortlet' class='portletSkin' style='margin-bottom:4px;'><div id='filterBox'></div></div>";
	var graphBox = "<div id='tabularViewPortlet' style='overflow: hidden;*width:98.8%;_width:100%;display:none'></div>";
	var gridBox = "<div id='dataGridContainer'  class='portletSkin' style='margin-bottom:4px;display:none;width:99.5%;_width:;overflow:hidden;'><div id='coverUpDiv_GridUtil' style='display:none; position:absolute; background-color:#ffffff; opacity:0.7; filter:alpha(opacity=70); height:100px; z-index:9999; font-size:20px; padding-left:20px; color:#666666'><br/>&nbsp;Loading...<br/><img src='images/kpiLoader.gif'/></div><div id='KUtilityBar' class='boxHeaderBG' ></div><div id='dataGrid' style='width:99.5%;height:375px;' onclick='closeUtilitys(\"force\")'></div><div id='tempDataGrid' style='height:375px;display:none'></div><div id='gridFooterArea' style='width:100%; height:40px; background-color:#cccccc'></div></div>";
	var headerViewBox = "<div id='headerViewPortlet'  style='display:none;margin:"+poMargin+"'></div>";
	var gridBox = headerViewBox + "<div id='dataGridContainer'  class='portletSkin' style='margin-bottom:4px;display:none;width:99.5%;_width:;overflow:hidden;'><div id='coverUpDiv_GridUtil' style='display:none; position:absolute; background-color:#ffffff;opacity:0.7; filter:alpha(opacity=70); height:100px; z-index:9999; font-size:20px; padding-left:20px; color:#666666'><br/>&nbsp;Loading...<br/><img src='images/kpiLoader.gif'/></div><div id='KUtilityBar' class='boxHeaderBG' ></div><div id='dataGrid' style='width:99.5%;height:375px;' onclick='closeUtilitys(\"force\")'></div><div id='tempDataGrid' style='height:375px;display:none'></div><div id='gridFooterPaginalArea' style='width:100%; height:25px; border-top:1px solid #ccc;  border-right:1px solid #ccc; border-left:1px solid #ccc;background-color:#f0f6f8'></div><div id='gridFooterArea' style='width:100%; height:40px; background-color:#cccccc'></div></div>";
	/*if(document.getElementById('KPIDetails_2_left')!=null && document.getElementById('KPIDetails_2_right')!=null){
	   document.getElementById('KPIDetails_2_left').style.display="none";
	   document.getElementById('KPIDetails_2_right').style.display="none";
	}*/

	//Clearing all the InnerHTML for all layouts
	document.getElementById('KPITemplate_Default').innerHTML = '';
	document.getElementById('KPIDetails_2_left').innerHTML = '';
	document.getElementById('KPIDetails_2_right').innerHTML = '';
	document.getElementById('KPIDetails_2_Bottom').innerHTML = '';
	document.getElementById('KPIDetails_3_left').innerHTML = '';
	document.getElementById('KPIDetails_3_right').innerHTML = '';

	if(strLayoutID=='1'){
		document.getElementById('KPITemplate_Default').style.display = 'block';
		document.getElementById('KPITemplate_Left').style.display = 'none';
		document.getElementById('KPITemplate_Right').style.display = 'none';

		if(strTemplateOrder=="1_2_3"){
			document.getElementById('KPITemplate_Default').innerHTML = filtersBox + graphBox + gridBox;
		}else if(strTemplateOrder=="2_1_3"){
			document.getElementById('KPITemplate_Default').innerHTML = graphBox + filtersBox + gridBox;
		}else if(strTemplateOrder=="3_2_1"){
			document.getElementById('KPITemplate_Default').innerHTML = gridBox + graphBox + filtersBox;
		}else if(strTemplateOrder=="3_1_2"){
			document.getElementById('KPITemplate_Default').innerHTML = gridBox + filtersBox + graphBox;
		}else if(strTemplateOrder=="2_3_1"){
			document.getElementById('KPITemplate_Default').innerHTML = graphBox + gridBox + filtersBox;
		}else if(strTemplateOrder=="1_3_2"){
			document.getElementById('KPITemplate_Default').innerHTML = filtersBox + gridBox + graphBox;
		}
	}
	if(strLayoutID=='2'){
		document.getElementById('KPITemplate_Default').style.display = 'none';
		document.getElementById('KPITemplate_Left').style.display = 'block';
		document.getElementById('KPITemplate_Right').style.display = 'none';

		if(strTemplateOrder=="1_2_3"){
			document.getElementById('KPIDetails_2_left').innerHTML = filtersBox;
			document.getElementById('KPIDetails_2_right').innerHTML = graphBox;
			document.getElementById('KPIDetails_2_Bottom').innerHTML = gridBox;
		}else if(strTemplateOrder=="2_1_3"){
			document.getElementById('KPIDetails_2_left').innerHTML = graphBox;
			document.getElementById('KPIDetails_2_right').innerHTML = filtersBox;
			document.getElementById('KPIDetails_2_Bottom').innerHTML = gridBox;
		}else if(strTemplateOrder=="3_2_1"){
			document.getElementById('KPIDetails_2_left').innerHTML = gridBox;
			document.getElementById('KPIDetails_2_right').innerHTML = graphBox;
			document.getElementById('KPIDetails_2_Bottom').innerHTML = filtersBox;
		}else if(strTemplateOrder=="3_1_2"){
			document.getElementById('KPIDetails_2_left').innerHTML = gridBox;
			document.getElementById('KPIDetails_2_right').innerHTML = filtersBox;
			document.getElementById('KPIDetails_2_Bottom').innerHTML = graphBox;
		}else if(strTemplateOrder=="2_3_1"){
			document.getElementById('KPIDetails_2_left').innerHTML = graphBox;
			document.getElementById('KPIDetails_2_right').innerHTML = gridBox;
			document.getElementById('KPIDetails_2_Bottom').innerHTML = filtersBox;
		}else if(strTemplateOrder=="1_3_2"){
			document.getElementById('KPIDetails_2_left').innerHTML = filtersBox;
			document.getElementById('KPIDetails_2_right').innerHTML = gridBox;
			document.getElementById('KPIDetails_2_Bottom').innerHTML = graphBox;
		}
	}
	if(strLayoutID=='3'){
		document.getElementById('KPITemplate_Default').style.display = 'none';
		document.getElementById('KPITemplate_Left').style.display = 'none';
		document.getElementById('KPITemplate_Right').style.display = 'block';

		if(strTemplateOrder=="1_2_3"){
			document.getElementById('KPIDetails_3_left').innerHTML = filtersBox + graphBox;
			document.getElementById('KPIDetails_3_right').innerHTML = gridBox;
		}else if(strTemplateOrder=="2_1_3"){
			document.getElementById('KPIDetails_3_left').innerHTML =  graphBox + filtersBox;
			document.getElementById('KPIDetails_3_right').innerHTML = gridBox;
		}else if(strTemplateOrder=="3_2_1"){
			document.getElementById('KPIDetails_3_left').innerHTML = gridBox + graphBox;
			document.getElementById('KPIDetails_3_right').innerHTML = filtersBox;
		}else if(strTemplateOrder=="3_1_2"){
			document.getElementById('KPIDetails_3_left').innerHTML = gridBox + filtersBox;
			document.getElementById('KPIDetails_3_right').innerHTML = graphBox;
		}else if(strTemplateOrder=="2_3_1"){
			document.getElementById('KPIDetails_3_left').innerHTML = graphBox + gridBox;
			document.getElementById('KPIDetails_3_right').innerHTML = filtersBox;
		}else if(strTemplateOrder=="1_3_2"){
			document.getElementById('KPIDetails_3_left').innerHTML = filtersBox + gridBox;
			document.getElementById('KPIDetails_3_right').innerHTML = graphBox;
		}
	}
	document.getElementById('gridFooterPaginalArea').innerHTML = "<div id='pagination' class='pagination'><div style='float:left; width:200px; text-align:left;' id='recinfoArea'></div><div style='float:right; width:190px; text-align:right;display:block;' id='pagingOptionArea'><%= ResourceUtil.getLabel('arc.show', locale)%></div><div style='text-align:center;' id='pagingArea'></div></div>";
	setDataGridDrag();
}
//Layoutset code ends

	// prasmit - 14-July-2009
	// Remove specified element from the given string
	function removeElement(element, arrStr){
		var testStr = '';
		var arr = arrStr.split(',');
		var elementIndex;
		for(var s=0; s<arr.length; s++){
			if(arr[s]==element){
				elementIndex = s;
			}
		}
		arr.splice(elementIndex,1);
		for(var i=0; i<arr.length; i++){
			if(testStr.length == 0){
				testStr = arr[i];
			}
			else{
				testStr = testStr + ',' + arr[i];
			}
		}
		return testStr;
	}

/*Cookie setting used in Login and Change password - starts*/
	function Set_Cookie( name, value, expires, path, domain, secure )
	{
		var today = new Date();
		today.setTime( today.getTime() );

		if ( expires )
		{
		expires = expires * 1000 * 60 * 60 * 24;
		}
		var expires_date = new Date( today.getTime() + (expires) );

		document.cookie = name + "=" +escape( value ) +
		( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
		( ( path ) ? ";path=" + path : "" ) +
		( ( domain ) ? ";domain=" + domain : "" ) +
		( ( secure ) ? ";secure" : "" );
	}

	function Get_Cookie( check_name ) {
		var a_all_cookies = document.cookie.split( ';' );
		var a_temp_cookie = '';
		var cookie_name = '';
		var cookie_value = '';
		var b_cookie_found = false;

		for ( i = 0; i < a_all_cookies.length; i++ )
		{
			a_temp_cookie = a_all_cookies[i].split( '=' );
			cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');
			if ( cookie_name == check_name )
			{
				b_cookie_found = true;
				if ( a_temp_cookie.length > 1 )
				{
					cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
				}
				return cookie_value;
				break;
			}
			a_temp_cookie = null;
			cookie_name = '';
		}
		if ( !b_cookie_found )
		{
			return null;
		}
	}

	function Delete_Cookie( name, path, domain ) {
		if ( Get_Cookie( name ) ) document.cookie = name + "=" +
		( ( path ) ? ";path=" + path : "") +
		( ( domain ) ? ";domain=" + domain : "" ) +
		";expires=Thu, 01-Jan-1970 00:00:01 GMT";
	}
/*Cookie setting used in Login and Change password - ends*/

function  dhxLoadFilter(item){
	treeboxbox_treeFilter.closeAllItems(0); treeboxbox_treeFilter.openAllItems(0);
    var v;
	v=dhxCombo.getSelectedValue();
	var flag = true;
	var chkVals = dhxCombo.getChecked();

	var values = new Array();
	values = hierFilter.split(',');
	if(v == 'WTD' || v == 'QTD' || v == 'MTD' || v == 'YTD')
	{
		showHidePeriodLayers(document.getElementById('layer2'),'none');
		showHidePeriodLayers(document.getElementById('layer1'),'none');
		showHidePeriodLayers(document.getElementById('layer3'),'none');
		showHidePeriodLayers(document.getElementById('layer4'),'none');
		showHidePeriodLayers(document.getElementById('layer5'),'none');

		showHidePeriodLayers(document.getElementById('layer6'),'none');
		showHidePeriodLayers(document.getElementById('layer7'),'none');
		showHidePeriodLayers(document.getElementById('layer8'),'none');
		showHidePeriodLayers(document.getElementById('layer9'),'none');
		showHidePeriodLayers(document.getElementById('layer10'),'none');

		showHidePeriodLayers(document.getElementById('quarterRangeStart'),'none');
		showHidePeriodLayers(document.getElementById('quarterRangeEnd'),'none');
		showHidePeriodLayers(document.getElementById('quarterRangeYearFrom'),'none');
		showHidePeriodLayers(document.getElementById('quarterRangeYearTo'),'none');
		showHidePeriodLayers(document.getElementById('weekRangeStart'),'none');
		showHidePeriodLayers(document.getElementById('weekRangeEnd'),'none');
		//showHidePeriodLayers(document.getElementById('lastXPeriodLayer'),'none');
		showHidePeriodLayers(document.getElementById('lastXPeriodLayer1'),'none');
		showHidePeriodLayers(document.getElementById('lastXPeriodLayer2'),'none');
		showHidePeriodLayers(document.getElementById('lastXPeriodLayer3'),'none');
		showHidePeriodLayers(document.getElementById('lastXPeriodLayer4'),'none');

		for(var valCnt = 0; valCnt<values.length; valCnt++){
			var dynperiod = values[valCnt];
			if(document.getElementById(dynperiod)){
				document.getElementById(dynperiod).style.display="none";
			}
		}
	}else if(v == 'Monthly')
	{
		if(flag){
			document.form1.month.options[0].selected=true;
			document.form1.year.options[0].selected=true;
		}

		showHidePeriodLayers(document.getElementById('layer2'),'inline');
		showHidePeriodLayers(document.getElementById('layer1'),'none');
		showHidePeriodLayers(document.getElementById('layer4'),'none');
		showHidePeriodLayers(document.getElementById('layer3'),'inline');
		showHidePeriodLayers(document.getElementById('layer5'),'none');
		showHidePeriodLayers(document.getElementById('layer6'),'none');
		showHidePeriodLayers(document.getElementById('layer7'),'none');
		showHidePeriodLayers(document.getElementById('layer8'),'none');
		showHidePeriodLayers(document.getElementById('layer9'),'none');
		showHidePeriodLayers(document.getElementById('layer10'),'none');
		showHidePeriodLayers(document.getElementById('quarterRangeStart'),'none');
		showHidePeriodLayers(document.getElementById('quarterRangeEnd'),'none');
		showHidePeriodLayers(document.getElementById('quarterRangeYearFrom'),'none');
		showHidePeriodLayers(document.getElementById('quarterRangeYearTo'),'none');
		showHidePeriodLayers(document.getElementById('weekRangeStart'),'none');
		showHidePeriodLayers(document.getElementById('weekRangeEnd'),'none');
		//showHidePeriodLayers(document.getElementById('lastXPeriodLayer'),'none');
		showHidePeriodLayers(document.getElementById('lastXPeriodLayer1'),'none');
		showHidePeriodLayers(document.getElementById('lastXPeriodLayer2'),'none');
		showHidePeriodLayers(document.getElementById('lastXPeriodLayer3'),'none');
		showHidePeriodLayers(document.getElementById('lastXPeriodLayer4'),'none');

		for(var valCnt = 0; valCnt<values.length; valCnt++){
			var dynperiod = values[valCnt];
			if(document.getElementById(dynperiod)){
				document.getElementById(dynperiod).style.display="none";
			}
		}
	}else if(v == 'Quarterly')
	{
		if(flag){
			document.form1.pquarter.options[0].selected=true;
	    	document.form1.year.options[0].selected=true;
	    }
		showHidePeriodLayers(document.getElementById('layer1'),'inline');
		showHidePeriodLayers(document.getElementById('layer2'),'none');
		showHidePeriodLayers(document.getElementById('layer4'),'none');
		showHidePeriodLayers(document.getElementById('layer3'),'inline');
		showHidePeriodLayers(document.getElementById('layer5'),'none');
		showHidePeriodLayers(document.getElementById('layer6'),'none');
		showHidePeriodLayers(document.getElementById('layer7'),'none');
		showHidePeriodLayers(document.getElementById('layer8'),'none');
		showHidePeriodLayers(document.getElementById('layer9'),'none');
		showHidePeriodLayers(document.getElementById('layer10'),'none');
		showHidePeriodLayers(document.getElementById('quarterRangeStart'),'none');
		showHidePeriodLayers(document.getElementById('quarterRangeEnd'),'none');
		showHidePeriodLayers(document.getElementById('quarterRangeYearFrom'),'none');
		showHidePeriodLayers(document.getElementById('quarterRangeYearTo'),'none');
		showHidePeriodLayers(document.getElementById('weekRangeStart'),'none');
		showHidePeriodLayers(document.getElementById('weekRangeEnd'),'none');
		//showHidePeriodLayers(document.getElementById('lastXPeriodLayer'),'none');
		showHidePeriodLayers(document.getElementById('lastXPeriodLayer1'),'none');
		showHidePeriodLayers(document.getElementById('lastXPeriodLayer2'),'none');
		showHidePeriodLayers(document.getElementById('lastXPeriodLayer3'),'none');
		showHidePeriodLayers(document.getElementById('lastXPeriodLayer4'),'none');
		for(var valCnt = 0; valCnt<values.length; valCnt++){
			var dynperiod = values[valCnt];
			if(document.getElementById(dynperiod)){
				document.getElementById(dynperiod).style.display="none";
			}
		}
	}else if(v == 'Yearly')
	{
		if(flag){
			document.form1.year.options[0].selected=true;
		}
		showHidePeriodLayers(document.getElementById('layer1'),'none');
	    showHidePeriodLayers(document.getElementById('layer2'),'none');
		showHidePeriodLayers(document.getElementById('layer4'),'none');
		showHidePeriodLayers(document.getElementById('layer3'),'inline');
		showHidePeriodLayers(document.getElementById('layer5'),'none');
		showHidePeriodLayers(document.getElementById('layer6'),'none');
		showHidePeriodLayers(document.getElementById('layer7'),'none');
		showHidePeriodLayers(document.getElementById('layer8'),'none');
		showHidePeriodLayers(document.getElementById('layer9'),'none');
		showHidePeriodLayers(document.getElementById('layer10'),'none');
		showHidePeriodLayers(document.getElementById('quarterRangeStart'),'none');
		showHidePeriodLayers(document.getElementById('quarterRangeEnd'),'none');
		showHidePeriodLayers(document.getElementById('quarterRangeYearFrom'),'none');
		showHidePeriodLayers(document.getElementById('quarterRangeYearTo'),'none');
		showHidePeriodLayers(document.getElementById('weekRangeStart'),'none');
		showHidePeriodLayers(document.getElementById('weekRangeEnd'),'none');
		//showHidePeriodLayers(document.getElementById('lastXPeriodLayer'),'none');
		showHidePeriodLayers(document.getElementById('lastXPeriodLayer1'),'none');
		showHidePeriodLayers(document.getElementById('lastXPeriodLayer2'),'none');
		showHidePeriodLayers(document.getElementById('lastXPeriodLayer3'),'none');
		showHidePeriodLayers(document.getElementById('lastXPeriodLayer4'),'none');
		for(var valCnt = 0; valCnt<values.length; valCnt++){
			var dynperiod = values[valCnt];
			if(document.getElementById(dynperiod)){
				document.getElementById(dynperiod).style.display="none";
			}
		}
	}else if(v == 'Halfyearly')
	{
		if(flag){
			document.form1.halfyearly.options[0].selected=true;
			document.form1.year.options[0].selected=true;
		}
		showHidePeriodLayers(document.getElementById('layer4'),'inline');
	    showHidePeriodLayers(document.getElementById('layer2'),'none');
		showHidePeriodLayers(document.getElementById('layer1'),'none');
		showHidePeriodLayers(document.getElementById('layer3'),'inline');
		showHidePeriodLayers(document.getElementById('layer5'),'none');
		showHidePeriodLayers(document.getElementById('layer6'),'none');
		showHidePeriodLayers(document.getElementById('layer7'),'none');
		showHidePeriodLayers(document.getElementById('layer8'),'none');
		showHidePeriodLayers(document.getElementById('layer9'),'none');
		showHidePeriodLayers(document.getElementById('layer10'),'none');
		showHidePeriodLayers(document.getElementById('quarterRangeStart'),'none');
		showHidePeriodLayers(document.getElementById('quarterRangeEnd'),'none');
		showHidePeriodLayers(document.getElementById('quarterRangeYearFrom'),'none');
		showHidePeriodLayers(document.getElementById('quarterRangeYearTo'),'none');
		showHidePeriodLayers(document.getElementById('weekRangeStart'),'none');
		showHidePeriodLayers(document.getElementById('weekRangeEnd'),'none');
		//showHidePeriodLayers(document.getElementById('lastXPeriodLayer'),'none');
		showHidePeriodLayers(document.getElementById('lastXPeriodLayer1'),'none');
		showHidePeriodLayers(document.getElementById('lastXPeriodLayer2'),'none');
		showHidePeriodLayers(document.getElementById('lastXPeriodLayer3'),'none');
		showHidePeriodLayers(document.getElementById('lastXPeriodLayer4'),'none');

		for(var valCnt = 0; valCnt<values.length; valCnt++){
			var dynperiod = values[valCnt];
			if(document.getElementById(dynperiod)){
				document.getElementById(dynperiod).style.display="none";
			}
		}
	}
	else if(v == 'Weekly')
	{

		showHidePeriodLayers(document.getElementById('layer5'),'inline');
		showHidePeriodLayers(document.getElementById('layer4'),'none');
		showHidePeriodLayers(document.getElementById('layer2'),'none');
		showHidePeriodLayers(document.getElementById('layer3'),'none');
		showHidePeriodLayers(document.getElementById('layer1'),'none');
		showHidePeriodLayers(document.getElementById('layer6'),'none');
		showHidePeriodLayers(document.getElementById('layer7'),'none');
		showHidePeriodLayers(document.getElementById('layer8'),'none');
		showHidePeriodLayers(document.getElementById('layer9'),'none');
		showHidePeriodLayers(document.getElementById('layer10'),'none');
		showHidePeriodLayers(document.getElementById('quarterRangeStart'),'none');
		showHidePeriodLayers(document.getElementById('quarterRangeEnd'),'none');
		showHidePeriodLayers(document.getElementById('quarterRangeYearFrom'),'none');
		showHidePeriodLayers(document.getElementById('quarterRangeYearTo'),'none');
		showHidePeriodLayers(document.getElementById('weekRangeStart'),'none');
		showHidePeriodLayers(document.getElementById('weekRangeEnd'),'none');
		//showHidePeriodLayers(document.getElementById('lastXPeriodLayer'),'none');
		showHidePeriodLayers(document.getElementById('lastXPeriodLayer1'),'none');
		showHidePeriodLayers(document.getElementById('lastXPeriodLayer2'),'none');
		showHidePeriodLayers(document.getElementById('lastXPeriodLayer3'),'none');
		showHidePeriodLayers(document.getElementById('lastXPeriodLayer4'),'none');
		for(var valCnt = 0; valCnt<values.length; valCnt++){
			var dynperiod = values[valCnt];
			if(document.getElementById(dynperiod)){
				document.getElementById(dynperiod).style.display="none";
			}
		}
	}
    else if(v == 'MonthRange')
	{

		showHidePeriodLayers(document.getElementById('layer6'),'inline');
		showHidePeriodLayers(document.getElementById('layer5'),'none');
		showHidePeriodLayers(document.getElementById('layer4'),'none');
		showHidePeriodLayers(document.getElementById('layer3'),'inline');
		showHidePeriodLayers(document.getElementById('layer2'),'none');
		showHidePeriodLayers(document.getElementById('layer1'),'none');
	    showHidePeriodLayers(document.getElementById('layer7'),'inline');
		showHidePeriodLayers(document.getElementById('layer8'),'inline');
		showHidePeriodLayers(document.getElementById('layer9'),'none');
		showHidePeriodLayers(document.getElementById('layer10'),'none');
		showHidePeriodLayers(document.getElementById('quarterRangeStart'),'none');
		showHidePeriodLayers(document.getElementById('quarterRangeEnd'),'none');
		showHidePeriodLayers(document.getElementById('quarterRangeYearFrom'),'none');
		showHidePeriodLayers(document.getElementById('quarterRangeYearTo'),'none');
		showHidePeriodLayers(document.getElementById('weekRangeStart'),'none');
		showHidePeriodLayers(document.getElementById('weekRangeEnd'),'none');
		//showHidePeriodLayers(document.getElementById('lastXPeriodLayer'),'none');
		showHidePeriodLayers(document.getElementById('lastXPeriodLayer1'),'none');
		showHidePeriodLayers(document.getElementById('lastXPeriodLayer2'),'none');
		showHidePeriodLayers(document.getElementById('lastXPeriodLayer3'),'none');
		showHidePeriodLayers(document.getElementById('lastXPeriodLayer4'),'none');
		for(var valCnt = 0; valCnt<values.length; valCnt++){
			var dynperiod = values[valCnt];
			if(document.getElementById(dynperiod)){
				document.getElementById(dynperiod).style.display="none";
			}
		}
	}
	else if(v == 'Daily' || v == 'Day')
	{

		showHidePeriodLayers(document.getElementById('layer6'),'none');
		showHidePeriodLayers(document.getElementById('layer5'),'none');
		showHidePeriodLayers(document.getElementById('layer4'),'none');
		showHidePeriodLayers(document.getElementById('layer3'),'none');
		showHidePeriodLayers(document.getElementById('layer2'),'none');
		showHidePeriodLayers(document.getElementById('layer1'),'none');
	    showHidePeriodLayers(document.getElementById('layer7'),'none');
		showHidePeriodLayers(document.getElementById('layer8'),'none');
		showHidePeriodLayers(document.getElementById('layer9'),'inline');
		if(v=='Day'){
			showHidePeriodLayers(document.getElementById('layer10'),'none');
			showHidePeriodLayers(document.getElementById('layer9A'),'none');
			showHidePeriodLayers(document.getElementById('layer9B'),'inline');
		}else{
			showHidePeriodLayers(document.getElementById('layer10'),'inline');
			showHidePeriodLayers(document.getElementById('layer9B'),'none');
			showHidePeriodLayers(document.getElementById('layer9A'),'inline');
		}

		showHidePeriodLayers(document.getElementById('quarterRangeStart'),'none');
		showHidePeriodLayers(document.getElementById('quarterRangeEnd'),'none');
		showHidePeriodLayers(document.getElementById('quarterRangeYearFrom'),'none');
		showHidePeriodLayers(document.getElementById('quarterRangeYearTo'),'none');
		showHidePeriodLayers(document.getElementById('weekRangeStart'),'none');
		showHidePeriodLayers(document.getElementById('weekRangeEnd'),'none');
		//showHidePeriodLayers(document.getElementById('lastXPeriodLayer'),'none');
		showHidePeriodLayers(document.getElementById('lastXPeriodLayer1'),'none');
		showHidePeriodLayers(document.getElementById('lastXPeriodLayer2'),'none');
		showHidePeriodLayers(document.getElementById('lastXPeriodLayer3'),'none');
		showHidePeriodLayers(document.getElementById('lastXPeriodLayer4'),'none');
		for(var valCnt = 0; valCnt<values.length; valCnt++){
			var dynperiod = values[valCnt];
			if(document.getElementById(dynperiod)){
				document.getElementById(dynperiod).style.display="none";
			}
		}
	}else if(v == 'QuarterRange')
	{
		if(flag){
			document.form1.startquarter.options[0].selected=true;
	    	document.form1.qtrfromyear.options[0].selected=true;

			document.form1.endquarter.options[0].selected=true;
	    	document.form1.qtrtoyear.options[0].selected=true;
	    }

		showHidePeriodLayers(document.getElementById('quarterRangeStart'),'inline');
		showHidePeriodLayers(document.getElementById('quarterRangeEnd'),'inline');
		showHidePeriodLayers(document.getElementById('quarterRangeYearFrom'),'inline');
		showHidePeriodLayers(document.getElementById('quarterRangeYearTo'),'inline');
		showHidePeriodLayers(document.getElementById('layer6'),'none');
		showHidePeriodLayers(document.getElementById('layer5'),'none');
		showHidePeriodLayers(document.getElementById('layer4'),'none');
		showHidePeriodLayers(document.getElementById('layer3'),'none');
		showHidePeriodLayers(document.getElementById('layer2'),'none');
		showHidePeriodLayers(document.getElementById('layer1'),'none');
	    showHidePeriodLayers(document.getElementById('layer7'),'none');
		showHidePeriodLayers(document.getElementById('layer8'),'none');
		showHidePeriodLayers(document.getElementById('layer9'),'none');
		showHidePeriodLayers(document.getElementById('layer10'),'none');
		showHidePeriodLayers(document.getElementById('weekRangeStart'),'none');
		showHidePeriodLayers(document.getElementById('weekRangeEnd'),'none');
		//showHidePeriodLayers(document.getElementById('lastXPeriodLayer'),'none');
		showHidePeriodLayers(document.getElementById('lastXPeriodLayer1'),'none');
		showHidePeriodLayers(document.getElementById('lastXPeriodLayer2'),'none');
		showHidePeriodLayers(document.getElementById('lastXPeriodLayer3'),'none');
		showHidePeriodLayers(document.getElementById('lastXPeriodLayer4'),'none');
		for(var valCnt = 0; valCnt<values.length; valCnt++){
			var dynperiod = values[valCnt];
			if(document.getElementById(dynperiod)){
				document.getElementById(dynperiod).style.display="none";
			}
		}
	}else if(v == 'WeekRange')
	{
		showHidePeriodLayers(document.getElementById('weekRangeStart'),'inline');
		showHidePeriodLayers(document.getElementById('weekRangeEnd'),'inline');
		showHidePeriodLayers(document.getElementById('quarterRangeStart'),'none');
		showHidePeriodLayers(document.getElementById('quarterRangeEnd'),'none');
		showHidePeriodLayers(document.getElementById('quarterRangeYearFrom'),'none');
		showHidePeriodLayers(document.getElementById('quarterRangeYearTo'),'none');
		showHidePeriodLayers(document.getElementById('layer6'),'none');
		showHidePeriodLayers(document.getElementById('layer5'),'none');
		showHidePeriodLayers(document.getElementById('layer4'),'none');
		showHidePeriodLayers(document.getElementById('layer3'),'none');
		showHidePeriodLayers(document.getElementById('layer2'),'none');
		showHidePeriodLayers(document.getElementById('layer1'),'none');
	    showHidePeriodLayers(document.getElementById('layer7'),'none');
		showHidePeriodLayers(document.getElementById('layer8'),'none');
		showHidePeriodLayers(document.getElementById('layer9'),'none');
		showHidePeriodLayers(document.getElementById('layer10'),'none');
		//showHidePeriodLayers(document.getElementById('lastXPeriodLayer'),'none');
		showHidePeriodLayers(document.getElementById('lastXPeriodLayer1'),'none');
		showHidePeriodLayers(document.getElementById('lastXPeriodLayer2'),'none');
		showHidePeriodLayers(document.getElementById('lastXPeriodLayer3'),'none');
		showHidePeriodLayers(document.getElementById('lastXPeriodLayer4'),'none');
		for(var valCnt = 0; valCnt<values.length; valCnt++){
			var dynperiod = values[valCnt];
			if(document.getElementById(dynperiod)){
				document.getElementById(dynperiod).style.display="none";
			}
		}
	}else if(v == 'LastXDays')
	{
		if(document.form1.lastxperiod)
			document.form1.lastxperiod.value = "DAYS";
		if(flag){
			document.form1.lastxperiod1.options[0].selected=true;
	    }
		showHidePeriodLayers(document.getElementById('lastXPeriodLayer1'),'inline');
		showHidePeriodLayers(document.getElementById('lastXPeriodLayer2'),'none');
		showHidePeriodLayers(document.getElementById('lastXPeriodLayer3'),'none');
		showHidePeriodLayers(document.getElementById('lastXPeriodLayer4'),'none');
		showHidePeriodLayers(document.getElementById('weekRangeStart'),'none');
		showHidePeriodLayers(document.getElementById('weekRangeEnd'),'none');
		showHidePeriodLayers(document.getElementById('quarterRangeStart'),'none');
		showHidePeriodLayers(document.getElementById('quarterRangeEnd'),'none');
		showHidePeriodLayers(document.getElementById('quarterRangeYearFrom'),'none');
		showHidePeriodLayers(document.getElementById('quarterRangeYearTo'),'none');
		showHidePeriodLayers(document.getElementById('layer6'),'none');
		showHidePeriodLayers(document.getElementById('layer5'),'none');
		showHidePeriodLayers(document.getElementById('layer4'),'none');
		showHidePeriodLayers(document.getElementById('layer3'),'none');
		showHidePeriodLayers(document.getElementById('layer2'),'none');
		showHidePeriodLayers(document.getElementById('layer1'),'none');
	    showHidePeriodLayers(document.getElementById('layer7'),'none');
		showHidePeriodLayers(document.getElementById('layer8'),'none');
		showHidePeriodLayers(document.getElementById('layer9'),'none');
		showHidePeriodLayers(document.getElementById('layer10'),'none');
		for(var valCnt = 0; valCnt<values.length; valCnt++){
			var dynperiod = values[valCnt];
			if(document.getElementById(dynperiod)){
				document.getElementById(dynperiod).style.display="none";
			}
		}
	}else if(v == 'LastXWeeks')
	{
		if(document.form1.lastxperiod)
			document.form1.lastxperiod.value = "WEEKS";
		if(flag){
			document.form1.lastxperiod2.options[0].selected=true;
	    }
	    showHidePeriodLayers(document.getElementById('lastXPeriodLayer1'),'none');
		showHidePeriodLayers(document.getElementById('lastXPeriodLayer2'),'inline');
		showHidePeriodLayers(document.getElementById('lastXPeriodLayer3'),'none');
		showHidePeriodLayers(document.getElementById('lastXPeriodLayer4'),'none');
		showHidePeriodLayers(document.getElementById('weekRangeStart'),'none');
		showHidePeriodLayers(document.getElementById('weekRangeEnd'),'none');
		showHidePeriodLayers(document.getElementById('quarterRangeStart'),'none');
		showHidePeriodLayers(document.getElementById('quarterRangeEnd'),'none');
		showHidePeriodLayers(document.getElementById('quarterRangeYearFrom'),'none');
		showHidePeriodLayers(document.getElementById('quarterRangeYearTo'),'none');
		showHidePeriodLayers(document.getElementById('layer6'),'none');
		showHidePeriodLayers(document.getElementById('layer5'),'none');
		showHidePeriodLayers(document.getElementById('layer4'),'none');
		showHidePeriodLayers(document.getElementById('layer3'),'none');
		showHidePeriodLayers(document.getElementById('layer2'),'none');
		showHidePeriodLayers(document.getElementById('layer1'),'none');
	    showHidePeriodLayers(document.getElementById('layer7'),'none');
		showHidePeriodLayers(document.getElementById('layer8'),'none');
		showHidePeriodLayers(document.getElementById('layer9'),'none');
		showHidePeriodLayers(document.getElementById('layer10'),'none');
		for(var valCnt = 0; valCnt<values.length; valCnt++){
			var dynperiod = values[valCnt];
			if(document.getElementById(dynperiod)){
				document.getElementById(dynperiod).style.display="none";
			}
		}
	}else if(v == 'LastXMonths')
	{
		if(document.form1.lastxperiod)
			document.form1.lastxperiod.value = "MONTHS";
		if(flag){
			document.form1.lastxperiod3.options[0].selected=true;
	    }
    	showHidePeriodLayers(document.getElementById('lastXPeriodLayer1'),'none');
    	showHidePeriodLayers(document.getElementById('lastXPeriodLayer2'),'none');
		showHidePeriodLayers(document.getElementById('lastXPeriodLayer3'),'inline');
		showHidePeriodLayers(document.getElementById('lastXPeriodLayer4'),'none');
		showHidePeriodLayers(document.getElementById('weekRangeStart'),'none');
		showHidePeriodLayers(document.getElementById('weekRangeEnd'),'none');
		showHidePeriodLayers(document.getElementById('quarterRangeStart'),'none');
		showHidePeriodLayers(document.getElementById('quarterRangeEnd'),'none');
		showHidePeriodLayers(document.getElementById('quarterRangeYearFrom'),'none');
		showHidePeriodLayers(document.getElementById('quarterRangeYearTo'),'none');

		showHidePeriodLayers(document.getElementById('layer6'),'none');
		showHidePeriodLayers(document.getElementById('layer5'),'none');
		showHidePeriodLayers(document.getElementById('layer4'),'none');
		showHidePeriodLayers(document.getElementById('layer3'),'none');
		showHidePeriodLayers(document.getElementById('layer2'),'none');
		showHidePeriodLayers(document.getElementById('layer1'),'none');
	    showHidePeriodLayers(document.getElementById('layer7'),'none');
		showHidePeriodLayers(document.getElementById('layer8'),'none');
		showHidePeriodLayers(document.getElementById('layer9'),'none');
		showHidePeriodLayers(document.getElementById('layer10'),'none');
		for(var valCnt = 0; valCnt<values.length; valCnt++){
			var dynperiod = values[valCnt];
			if(document.getElementById(dynperiod)){
				document.getElementById(dynperiod).style.display="none";
			}
		}
	}else if(v == 'LastXQuarters')
	{
		if(document.form1.lastxperiod)
			document.form1.lastxperiod.value = "QUARTERS";
		if(flag){
			document.form1.lastxperiod4.options[0].selected=true;
	    }
		showHidePeriodLayers(document.getElementById('lastXPeriodLayer1'),'none');
		showHidePeriodLayers(document.getElementById('lastXPeriodLayer2'),'none');
		showHidePeriodLayers(document.getElementById('lastXPeriodLayer3'),'none');
		showHidePeriodLayers(document.getElementById('lastXPeriodLayer4'),'inline');
		showHidePeriodLayers(document.getElementById('weekRangeStart'),'none');
		showHidePeriodLayers(document.getElementById('weekRangeEnd'),'none');
		showHidePeriodLayers(document.getElementById('quarterRangeStart'),'none');
		showHidePeriodLayers(document.getElementById('quarterRangeEnd'),'none');
		showHidePeriodLayers(document.getElementById('quarterRangeYearFrom'),'none');
		showHidePeriodLayers(document.getElementById('quarterRangeYearTo'),'none');
		showHidePeriodLayers(document.getElementById('layer6'),'none');
		showHidePeriodLayers(document.getElementById('layer5'),'none');
		showHidePeriodLayers(document.getElementById('layer4'),'none');
		showHidePeriodLayers(document.getElementById('layer3'),'none');
		showHidePeriodLayers(document.getElementById('layer2'),'none');
		showHidePeriodLayers(document.getElementById('layer1'),'none');
	    showHidePeriodLayers(document.getElementById('layer7'),'none');
		showHidePeriodLayers(document.getElementById('layer8'),'none');
		showHidePeriodLayers(document.getElementById('layer9'),'none');
		showHidePeriodLayers(document.getElementById('layer10'),'none');
		for(var valCnt = 0; valCnt<values.length; valCnt++){
			var dynperiod = values[valCnt];
			if(document.getElementById(dynperiod)){
				document.getElementById(dynperiod).style.display="none";
			}
		}
	}
	else
    {
		showHidePeriodLayers(document.getElementById('layer2'),'none');
		showHidePeriodLayers(document.getElementById('layer1'),'none');
		showHidePeriodLayers(document.getElementById('layer3'),'none');
		showHidePeriodLayers(document.getElementById('layer4'),'none');
		showHidePeriodLayers(document.getElementById('layer5'),'none');
		showHidePeriodLayers(document.getElementById('layer6'),'none');
		showHidePeriodLayers(document.getElementById('layer7'),'none');
		showHidePeriodLayers(document.getElementById('layer8'),'none');
		showHidePeriodLayers(document.getElementById('layer9'),'none');
		showHidePeriodLayers(document.getElementById('layer10'),'none');
		showHidePeriodLayers(document.getElementById('quarterRangeStart'),'none');
		showHidePeriodLayers(document.getElementById('quarterRangeEnd'),'none');
		showHidePeriodLayers(document.getElementById('quarterRangeYearFrom'),'none');
		showHidePeriodLayers(document.getElementById('quarterRangeYearTo'),'none');
		showHidePeriodLayers(document.getElementById('weekRangeStart'),'none');
		showHidePeriodLayers(document.getElementById('weekRangeEnd'),'none');
		//showHidePeriodLayers(document.getElementById('lastXPeriodLayer'),'none');
		showHidePeriodLayers(document.getElementById('lastXPeriodLayer1'),'none');
		showHidePeriodLayers(document.getElementById('lastXPeriodLayer2'),'none');
		showHidePeriodLayers(document.getElementById('lastXPeriodLayer3'),'none');
		showHidePeriodLayers(document.getElementById('lastXPeriodLayer4'),'none');

		for(var valCnt = 0; valCnt<values.length; valCnt++){
			var dynperiod = values[valCnt];
			if(v == dynperiod)
			{
				if(document.getElementById(dynperiod)){
					document.getElementById(dynperiod).style.display="inline";
				}
			}else
			{
				if(document.getElementById(dynperiod)){
					document.getElementById(dynperiod).style.display="none";
				}
			}
		}
	}

 }

 function checkExport(){
	if(document.getElementById('exportOptions')){
		document.getElementById('exportOptions').style.display = 'none';
	}
	if(document.getElementById('customizeLinkKpi')){
		document.getElementById('customizeLinkKpi').style.display = 'none';
	}
	if(document.getElementById('customizeG')){
		document.getElementById('customizeG').style.display = 'none';
	}
	if(document.getElementById('swapView')){
		document.getElementById('swapView').style.display = 'none';
	}
	if(document.getElementById('gridUtilityBar')){
		document.getElementById('gridUtilityBar').style.display = 'none';
	}
	if(document.getElementById('dbFunctionsBar')){
		document.getElementById('dbFunctionsBar').style.display = 'none';
	}
 }

  function fixPortletHeights(){
 //id-->>>filtersPortlet  dataGridContainer  tabularViewPortlet
	 if($('KPIDetails_2_left')==null || $('KPIDetails_2_right')==null)return;
	 if($('KPIDetails_2_left').offsetHeight<$('KPIDetails_2_right').offsetHeight){
		   if($('KPIDetails_2_left').childNodes[0].id=="tabularViewPortlet"){
		     Element.cleanWhitespace($('KPIDetails_2_left').childNodes[0]);
 	 	 	 Element.cleanWhitespace($('KPIDetails_2_left').childNodes[0].childNodes[0]);
 	 	 	 Element.cleanWhitespace($('KPIDetails_2_left').childNodes[0].childNodes[0].childNodes[0]);
		     $('KPIDetails_2_left').childNodes[0].childNodes[0].childNodes[0].style.height=$('KPIDetails_2_right').offsetHeight-3+"px";
		     $('treeboxbox_treeFilter').style.height = $('KPIDetails_2_right').childNodes[0].offsetHeight - 145 +"px";

		   }else if($('KPIDetails_2_left').childNodes[0].id=="filtersPortlet"){
		     $('KPIDetails_2_left').childNodes[0].style.height = $('KPIDetails_2_right').childNodes[0].offsetHeight - 6 +"px";
		     $('treeboxbox_treeFilter').style.height = $('KPIDetails_2_right').childNodes[0].offsetHeight - 145 +"px";
		   }
	 }else if($('KPIDetails_2_right').offsetHeight<$('KPIDetails_2_left').offsetHeight){
	 	 if($('KPIDetails_2_right').childNodes[0].id=="tabularViewPortlet"){
	 	 	 Element.cleanWhitespace($('KPIDetails_2_right').childNodes[0]);
 	 	 	 Element.cleanWhitespace($('KPIDetails_2_right').childNodes[0].childNodes[0]);
 	 	 	 Element.cleanWhitespace($('KPIDetails_2_right').childNodes[0].childNodes[0].childNodes[0]);
		     $('KPIDetails_2_right').childNodes[0].childNodes[0].childNodes[0].style.height=$('KPIDetails_2_left').offsetHeight-5+"px";
		 }else if($('KPIDetails_2_right').childNodes[0].id=="filtersPortlet"){
		     $('KPIDetails_2_right').childNodes[0].style.height = $('KPIDetails_2_left').childNodes[0].offsetHeight - 6 +"px";
		      $('treeboxbox_treeFilter').style.height = $('KPIDetails_2_right').childNodes[0].offsetHeight - 145 +"px";
		 }
	 }
 }

function iPrint(ptarget)
{
	ptarget.focus();
	ptarget.print();
}

function newTrafficHover()
{
	if(document.getElementById('trafficContainerDiv')){
		objTitle= document.getElementById('trafficContainerDiv').innerHTML;
		objTitle=objTitle.replace("TRFG:-","<img src='images/icon_expression_green.gif' hspace=2 border='0' align=absmiddle/>");
		objTitle=objTitle.replace("TRFY:-","<br/><img src='images/icon_expression_yellow.gif' hspace=2 border='0' align=absmiddle/>");
		objTitle=objTitle.replace("TRFR:-","<br/><img src='images/icon_expression_red.gif' border='0' hspace=2 align=absmiddle/>");
		objTitle=objTitle.replace("TRNG:-","<img src='images/icon_trendline_arrowgreen.gif' hspace=2 border='0' align=absmiddle/>");
		objTitle=objTitle.replace("TRNY:-","<br/><img src='images/icon_trendline_arrowyellow.gif' hspace=2 border='0' align=absmiddle/>");
		objTitle=objTitle.replace("TRNR:-","<br/><img src='images/icon_trendline_arrowred.gif' border='0' hspace=2 align=absmiddle/>");
		document.getElementById('trafficContainerDiv').innerHTML = objTitle;

		if(document.getElementById('trafficContainerDiv').getElementsByTagName("img").length==0)
		{
			document.getElementById('trafficContainerDiv').innerHTML='Traffic Light has not been Applied.';
		}

		TagToTip('trafficContainerDiv', BALLOON, true, ABOVE, true, PADDING, 10, TEXTALIGN, 'justify', OFFSETX, -10);
	}
}

function newTrendHover()
{
	if(document.getElementById('trendContainerDiv')){
		objTitle= document.getElementById('trendContainerDiv').innerHTML;
		objTitle=objTitle.replace("TRFG:-","<img src='images/icon_expression_green.gif' hspace=2 border='0' align=absmiddle/>");
		objTitle=objTitle.replace("TRFY:-","<br/><img src='images/icon_expression_yellow.gif' hspace=2 border='0' align=absmiddle/>");
		objTitle=objTitle.replace("TRFR:-","<br/><img src='images/icon_expression_red.gif' border='0' hspace=2 align=absmiddle/>");
		objTitle=objTitle.replace("TRNG:-","<img src='images/icon_trendline_arrowgreen.gif' hspace=2 border='0' align=absmiddle/>");
		objTitle=objTitle.replace("TRNY:-","<br/><img src='images/icon_trendline_arrowyellow.gif' hspace=2 border='0' align=absmiddle/>");
		objTitle=objTitle.replace("TRNR:-","<br/><img src='images/icon_trendline_arrowred.gif' border='0' hspace=2 align=absmiddle/>");
		document.getElementById('trendContainerDiv').innerHTML = objTitle;

		if(document.getElementById('trendContainerDiv').getElementsByTagName("img").length==0)
		{
			document.getElementById('trendContainerDiv').innerHTML='Trend Line has not been Applied.';
		}

		TagToTip('trendContainerDiv', BALLOON, true, ABOVE, true, PADDING, 10, TEXTALIGN, 'justify', OFFSETX, -10);
	}
}

function getMyRangeDate(fmObj,STDate,EDDate){
	var objEDDate = document.getElementById(EDDate);
	var objlastETlDate = document.getElementById('hdnToday');
	var objSTDate= document.getElementById(STDate);
	if(objSTDate.value != ''){
		var myETLArr=new Array(3);
		myETLArr[0]=objlastETlDate.value.split("-")[0];
		myETLArr[1]=objlastETlDate.value.split("-")[1];
		myETLArr[2]=objlastETlDate.value.split("-")[2];
		var myStartArr=new Array(3);
		myStartArr[0]=objSTDate.value.split("-")[0];
		myStartArr[1]=objSTDate.value.split("-")[1];
		myStartArr[2]=objSTDate.value.split("-")[2];
		gfPop.fPopCalendar(objEDDate,[[myStartArr[0],myStartArr[1],myStartArr[2]],[myETLArr[0],myETLArr[1],myETLArr[2]]], null);
		return false;
	}
	else{
		alert(generalMsg[48]);
		return false;
	}
}

// added for action bar enhancement
function setActionBar(actionID, actionName) {
	var checkedCount = validateSelectType();
	if (checkedCount == 0) {
		alert(scajsMsg[1].sub("_",$('kpiTitleSpan').innerHTML));
		return false;
	}

	$('hdnAction').value = "";
	if ($('hdnAction').value == "") {
		$('hdnAction').value = actionID;
	}

	var strURL = Form.serialize($(form1));
	var dcURL = 'hdnAction=' + document.getElementById('hdnAction').value + '&'
			+ 'hdnEntityID=' + document.getElementById('hdnEntityID').value
			+ '&' + 'hdnEntityValue='
			+ document.getElementById('hdnEntityValue').value + '&'
			+ 'hdnRowIndex=' + document.getElementById('hdnRowIndex').value;
	if (actionID == '0') {
		setAction('Approve');
	} else if (actionID == '1') {
		var oOptions = {
			method : "post",
			parameters : strURL,
			onSuccess : function(transport) {
				invokePopup("Note", "poRejectNote.jsp?" + strURL,
						"30,50", "400", "90");

			},
			onFailure : function(transport) {
				alert(transport.statusText);
			}
		};
		var oRequest = new Ajax.Request("wfValidatorServlet", oOptions);
	} else if (actionID == '5') {
		var oOptions = {
			method : "post",
			parameters : strURL,
			onSuccess : function(transport) {
				invokePopup("Cancel Note", "poRejectNote.jsp?" + strURL
						+ "&actionName=" + actionName, "30,50", "500", "90");
			},
			onFailure : function(transport) {
				alert(transport.statusText);
			}
		};
		var oRequest = new Ajax.Request("wfValidatorServlet", oOptions);
	} else if (actionID == '2') {
		if (checkedCount > 1) {
			alert(scajsMsg[2].sub("_",$('kpiTitleSpan').innerHTML));
			return false;
		}
		var oOptions = {
			method : "post",
			parameters : dcURL,
			onSuccess : function(transport) {
				invokePopup("Request Amendment",
						"createAmendment.jsp?" + dcURL, "30,50", "480", "90");
			},
			onFailure : function(transport) {
				alert(transport.statusText + "\n" + scajsMsg[4]);
			}
		};
		var oRequest = new Ajax.Request("discussionChainValidatorServlet",
				oOptions);

	} else if (actionID == '3' || actionID == '4') {
		if (checkedCount > 1) {
			if (actionID == '4') {
				alert(scajsMsg[6].sub("_", $('kpiTitleSpan').innerHTML));
			} else {
				alert(scajsMsg[5].sub("_", $('kpiTitleSpan').innerHTML));
			}

			return false;
		}
		var oOptions = {
			method : "post",
			parameters : dcURL,
			onSuccess : function(transport) {
				openWindow("myDiscussion.jsp?" + dcURL);
			},
			onFailure : function(transport) {
				alert(transport.statusText);
			}
		};
		var oRequest = new Ajax.Request("myDiscussionChainValidatorServlet",
				oOptions);

	}
}

/*function loadBCMPopup(urlVal){
	var strURL=Form.serialize($(form1));
	strURL = urlVal+"&fileType=pdf";
	openWindow("linkMeasureBCM.jsp?"+ encodeURIComponent(strURL));
}*/

function loadBCMPopup(rowIndex,columnId,cellValue){
	var strURL="fileType=pdf&rowIndex="+rowIndex+"&columnId="+columnId+"&cellValue="+cellValue+"&"+columnId+"="+cellValue;
	openWindow("linkMeasureBCM.jsp?url="+strURL);
}

function openExportDialog(fileLoc){
	window.open(fileLoc, "", "toolbar=no,location=no,directories=no,menubar=no,scrollbars=yes,resizable=yes,width=800,height=500,left=100,top=100");
}

function setActionBar(actionID, actionName) {
	var checkedCount = validateSelectType();
	if (checkedCount == 0) {
		alert(scajsMsg[1].sub("_",
				$('kpiTitleSpan').innerHTML));
		return false;
	}

	$('hdnAction').value = "";
	if ($('hdnAction').value == "") {
		$('hdnAction').value = actionID;
	}

	var strURL = Form.serialize($(form1));
	var dcURL = 'hdnAction=' + document.getElementById('hdnAction').value + '&'
			+ 'hdnEntityID=' + document.getElementById('hdnEntityID').value
			+ '&' + 'hdnEntityValue='
			+ document.getElementById('hdnEntityValue').value + '&'
			+ 'hdnRowIndex=' + document.getElementById('hdnRowIndex').value;
	if (actionID == '0') {
		setAction('Approve');
	} else if (actionID == '1') {
		var oOptions = {
			method : "post",
			parameters : strURL,
			onSuccess : function(transport) {
				invokePopup("Note", "poRejectNote.jsp?" + strURL,
						"30,50", "400", "90");

			},
			onFailure : function(transport) {
				alert(transport.statusText);
			}
		};
		var oRequest = new Ajax.Request("wfValidatorServlet", oOptions);
	} else if (actionID == '5') {
		var oOptions = {
			method : "post",
			parameters : strURL,
			onSuccess : function(transport) {
				invokePopup("Cancel Note", "poRejectNote.jsp?" + strURL
						+ "&actionName=" + actionName, "30,50", "500", "90");
			},
			onFailure : function(transport) {
				alert(transport.statusText);
			}
		};
		var oRequest = new Ajax.Request("wfValidatorServlet", oOptions);
	} else if (actionID == '2') {
		if (checkedCount > 1) {
			alert(scajsMsg[2].sub("_",$('kpiTitleSpan').innerHTML));
			return false;
		}
		var oOptions = {
			method : "post",
			parameters : dcURL,
			onSuccess : function(transport) {
				invokePopup("Request Amendment",
						"createAmendment.jsp?" + dcURL, "30,50", "480", "90");
			},
			onFailure : function(transport) {
				alert(transport.statusText + "\n" + scajsMsg[4]);
			}
		};
		var oRequest = new Ajax.Request("discussionChainValidatorServlet",
				oOptions);

	} else if (actionID == '3' || actionID == '4') {
		if (checkedCount > 1) {
			if (actionID == '4') {
				alert(scajsMsg[6].sub("_", $('kpiTitleSpan').innerHTML));
			} else {
				alert(scajsMsg[5].sub("_", $('kpiTitleSpan').innerHTML));
			}

			return false;
		}
		var oOptions = {
			method : "post",
			parameters : dcURL,
			onSuccess : function(transport) {
				openWindow("myDiscussion.jsp?" + dcURL);
			},
			onFailure : function(transport) {
				alert(transport.statusText);
			}
		};
		var oRequest = new Ajax.Request("myDiscussionChainValidatorServlet",
				oOptions);

	}
}

function validateSelectType(){
	var checkedCount = 0;
	var checked = false;
	allSelects = document.getElementById('dataGrid').getElementsByTagName("input");
	for (var j = 0 ; j < allSelects.length ; j++ ){
		if (allSelects[j].type=="checkbox" || allSelects[j].type=="radio"){
			if(allSelects[j].checked)
			{
				checked = true ;
				checkedCount = checkedCount + 1;
			}
		}
	}
	return checkedCount;
}

function resizeHeaderLoader()
{
	if(document.getElementById('dataGrid'))
	{
		headerRow = document.getElementById('dataGrid').getElementsByTagName('table');
		for(i=0; i<headerRow.length; i++)
		{
			if(headerRow[i].attributes["class"].value=='hdr')
			{
				if(document.getElementById('coverUpDiv_GridUtil'))
				document.getElementById('coverUpDiv_GridUtil').style.height=headerRow[i].offsetHeight + 55 + "px";
				break;
			}
		}
	}
}
function attachRTEchkEvnt(){
	document.getElementById("chkSrcrte1").onclick=function(){
		toggleHTMLSrc('rte1',true,true);
		displayRTEHeight(this);
	 }
}

function displayRTEHeight(){
  if(arguments[0].checked)
  	document.getElementById("rte1").style.height=(document.getElementById("rte1").offsetHeight+45)+"px";
  else
  	document.getElementById("rte1").style.height=(document.getElementById("rte1").offsetHeight-45)+"px";
}
/*
Commented by Manoj for 0006663
function selectCheckbox(rowId,cellIndex){
	if(cellIndex != 0){
		mygrid.cells(rowId,0).cell.parentNode.childNodes[0].childNodes[0].checked = true;
		mygrid.cells(rowId,0).cell.parentNode.childNodes[0].childNodes[0].onclick();
	}
}
*/

function workflowActionPerformer(actionName) {

	var wfKey = "";
	var hdnEntityID=document.getElementById('hdnEntityID').value;
	if($("hdnWFKey"))
		wfKey  = $("hdnWFKey").value;

	if (actionName == "Claim All Tasks") {
		var params = 'actionName=' + actionName + '&hdnWFKey=' + wfKey
		+ '&hdnEntityID=' + hdnEntityID;
		var oOptions = {
			method : "post",
			parameters : params,
			onSuccess : function(transport) {
				var json = transport.responseText.evalJSON();
				var msgText = json.msg;
				var taskForm = json.task_form;
				if (null != msgText && msgText.length > 0) {
					alert(json.msg);
					kpiClick($("view_id").value, "kpiLeftMenu"
							+ $("view_id").value, "kpiClick");
				} else {
					alert(json.err);
				}
			},
			onFailure : function(transport) {
				alert("Error in processing!");
			}
		};
		var oRequest = new Ajax.Request("wfServlet", oOptions);

	} else {

		var checkedCount = validateSelectType();
		if (checkedCount == 0) {
			alert(scajsMsg[1].sub("_", $('kpiTitleSpan').innerHTML));
			return false;
		}

		var rowIndex = document.getElementById('hdnRowIndex').value;
		var entityValues = document.getElementById('hdnEntityValue').value;
		var params = 'rowIndex=' + rowIndex + '&' + 'actionName=' + actionName
		+ '&' + 'entityValues=' + entityValues + '&hdnEntityID='
		+ hdnEntityID + '&hdnWFKey=' + wfKey + '&view_id=' + $("view_id").value;

		var wfStatusArray = $("hdnwfStatusValue").value.split(",");

		if (isAllSameStatus(wfStatusArray)) {
			if (isRejectOrCancelAction(actionName)) {
				invokePopup("Note", "poRejectNote.jsp?" + params, "30,50",
						"400", "90");
			} else {
				var oOptions = {
						method : "post",
						parameters : params,
						onSuccess : function(transport) {
							var json = transport.responseText.evalJSON();
						var msgText = json.msg;
						var taskForm = json.task_form;
						if (null != msgText && msgText.length > 0) {
								alert(json.msg);
							kpiClick($("view_id").value, "kpiLeftMenu"
									+ $("view_id").value, "kpiClick");
						} else {
							alert(json.err);
						}
					},
					onFailure : function(transport) {
						alert("Error in processing!");
					}
				};
				var oRequest = new Ajax.Request("wfServlet", oOptions);
			}
		} else {
			alert(generalMsg[78]);
		}
	}
}

function isAllSameStatus(wfStatusArray){
	if(wfStatusArray.length>1)
	{
		var firstStatusValue  = wfStatusArray[0];
		for(var j=1; j<wfStatusArray.length; j++)
		{
			if(wfStatusArray[j] != firstStatusValue)
			{
				return false;
			}
		}
	}
	return true;
}

/**
 * This method is used to populate the Workflow Task Buttons on the screen
 *
 * @param formName
 * @returns {Boolean}
 */
function workflowFormPerformer(formName) {
	var checkedCount = validateSelectType();
	if (checkedCount == 0) {
		alert(scajsMsg[1].sub("_", $('kpiTitleSpan').innerHTML));
		return false;
	}
	var npiKey = $("hdnEntityValue").value;
	var wfKey = $("wf_key").value;

	var params = {
			"formAction" : "taskFormButtons",
			"npiKey" : npiKey,
			"wfKey" : wfKey,
			"formName" : formName
	};
	var oOptions = {
		method : "post",
			parameters : params,
		onSuccess : function(transport) {
			var json = transport.responseText.evalJSON();
			var errText = json.err;
			if (null != errText && errText.length > 0) {
				alert(errText);
			} else {
				invokePopup1("Task Form", formName + "?taskButtons="
					+ json["TASK_BUTTONS"], "30,30", "500", "95");
			}
		},
		onFailure : function(transport) {
			alert(transport.statusText);
		}
	};
	var oRequest = new Ajax.Request("npiServlet", oOptions);
}

/**
 * This method is used to perform the Workflow Action as per the Task Button
 * clicked
 *
 * @param taskName
 * @param encodeHashMap
 */
function workflowTaskPerformer(taskName, encodeHashMap) {
	var wfKey = parent.document.getElementById('wf_key').value;
	var params = {
			"action" : taskName,
			"encodeHashMap" : encodeHashMap,
			"wfKey" : wfKey
	};

	if (isRejectOrCancelAction(taskName)) {
		var params = "action=" + taskName + "&wfKey=" + wfKey;
		invokePopup("Note", "npi_reject_cancel_note.jsp?" + params, "30,50",
				"300", "65");
	} else {
		var oOptions = {
			method : "post",
			parameters : params,
			onSuccess : function(transport) {
				var json = transport.responseText.evalJSON();
				var msgText = json.msg;
				if (null != msgText && msgText.length > 0) {
					parent.killPopup1();
					alert(json.msg);
					var viewid = parent.document.getElementById('view_id').value;
					parent.kpiClick(viewid, 'kpiLeftMenu' + viewid, 'kpiClick');
				}
			},
			onFailure : function(transport) {
				var json = transport.responseText.evalJSON();
				var msgText = json.msg;
				if (null != msgText && msgText.length > 0) {
					parent.killPopup1();
					alert(json.msg);
				}
			}
		};
		var oRequest = new Ajax.Request("npiServlet", oOptions);
	}
}

/**
 * This method checks whether the Task button clicked is a 'Reject' or 'Cancel'
 *
 * @param taskName
 * @returns {Boolean}
 */
function isRejectOrCancelAction(taskName) {
	var rejectOrCancel = false;
	if (taskName.length > 0
			&& (taskName.indexOf('Reject') >= 0 || taskName.indexOf('Cancel') >= 0 || taskName.indexOf('IssueActionSlip') >= 0)) {
		rejectOrCancel = true;
	}
	return rejectOrCancel;
}

function imagePreview(){
	invokePopup1('Image Preview', 'npi_imagePreview.jsp?path='+ imageName+'&npiKey='+npiKey, '40,120','350', '70');
}

function expandCollapseTasks(obj){
	if(obj.src.indexOf("minus")>=0){
		obj.src = obj.src.replace("minus","plus");
		obj.title = 'Expand';
		obj.parentNode.parentNode.parentNode.parentNode.parentNode.childNodes[1].style.display="none";
	}else{
		obj.src = obj.src.replace("plus","minus");
		obj.title = 'Collapse';
		obj.parentNode.parentNode.parentNode.parentNode.parentNode.childNodes[1].style.display="block";
	}
	/*if(document.getElementById("taskGrid_").style.display == "block"){
		obj.childNodes[0].src = 'images/plus.jpg';
		obj.childNodes[0].title = 'Expand';
		document.getElementById("taskGrid_"+val).style.display = "none";
	}else{
		obj.childNodes[0].src = 'images/minus.jpg';
		obj.childNodes[0].title = 'Collapse';
		document.getElementById("taskGrid_"+val).style.display = "block";
	}*/
}

var sortFlag = false;
function toggleTreeSort(treeObj,rootID,imgID){
	if(document.getElementById(imgID).src.indexOf("imgTreeSort_ASC") > 0){
		document.getElementById(imgID).src = 'images/imgTreeSort_DESC.gif';
		document.getElementById(imgID).title = "Sort DESC";
		treeObj.sortTree(rootID,'DESC',true);
	}else{
		document.getElementById(imgID).src = 'images/imgTreeSort_ASC.gif';
		document.getElementById(imgID).title = "Sort ASC";
		treeObj.sortTree(rootID,'ASC',true);
	}

}

function bookmarkARC(strURL,strTitle){
	if (document.all)
	  window.external.AddFavorite(strURL, strTitle);
	else if (window.sidebar)
	  window.sidebar.addPanel(strTitle, strURL, "")
	else if (window.sidebar&&window.sidebar.addPanel)
	  window.sidebar.addPanel(strTitle,strURL,"");
}

//FireFox Fix adding className
function addClassName(obj, className){
	if (BrowserDetect.browser=="Explorer")	obj.setAttribute("className", className);
	else obj.setAttribute("class", className);
}

function truncateEllipse(obj, length){
	alert(obj.innerHTML);
	obj.innerHTML = obj.innerHTML.substring(0, length)+'...';
}

function getKeyCode(evt){
	var code = 0;
	if(BrowserDetect.browser=="Explorer")	code = evt.keyCode;
	else if( BrowserDetect.browser!="Explorer" ) code = evt.which;
	return code;
}

function getObjInnerText(obj){
	if (BrowserDetect.browser=="Explorer")
		return obj.innerText;
	else
		return obj.text;
}

function next(elem) {
  do {
      elem = elem.nextSibling;
    } while (elem && elem.nodeType != 1);
    return elem;
}

function setDHTMLXTreeHeight(treeName,val,val1){
	var treeLen = treeName.split(",");
	var heightLen = val.split(",");
	for(i=0; i<treeLen.length; i++){
		if(val1){
			$(treeLen[i]).childNodes[0].style.height = heightLen[i]+"px";
		}
		else{
			$(treeLen[i]).childNodes[0].style.height = val+"px";
		}
	}
}

function stopPropogations(evt)
{
    var e=(evt)?evt:window.event;
    if (window.event) {
        e.cancelBubble=true;
    } else {
        e.stopPropagation();
    }
}
function sucessAlertKillPopup(msg, popName,reload){
	if(BrowserDetect.browser=='Explorer'){
		eval('parent.'+popName+'();');
		alert(msg);
		if(reload && reload != null){parent.location.reload();}
	}
	else{
		alert(msg);
		if(reload && reload != null){parent.location.reload();}
		eval('parent.'+popName+'();');
	}
}
function autoEllipseText(element, text, width)
{
   element.innerHTML = '<span id="ellipsisSpan" style="white-space:nowrap;">' + text + '</span>';
   var inSpan = document.getElementById('ellipsisSpan');
   if(inSpan.offsetWidth > width)
   {
      var i = 1;
      inSpan.innerHTML = '';
      while(inSpan.offsetWidth < (width) && i < text.length)
      {
         inSpan.innerHTML = text.substr(0,i) + '...';
         i++;
      }

      returnText = inSpan.innerHTML;
      element.innerHTML = '';
      return returnText;
   }
   return text;
}
function getMyInnerText(elt) {
	var _innerText = elt.innerText;
	if (_innerText == undefined) {
  		_innerText = elt.innerHTML.replace(/<[^>]+>/g,"");
	}
	return _innerText;
}

function elipseTextFF(txt, styleWidth, limition){
	if (BrowserDetect.browser!="Explorer"){
		if( (txt.length*7) >= styleWidth ){
			return txt.substr(0, limition)+'...';
		}
	}
	return txt;
}
function doElipseTextFFById(ele, styleWidth, limition, moduleName){
	if (BrowserDetect.browser!="Explorer"){
		if(moduleName == "kpiMenu"){
			$(ele).firstChild.data = elipseTextFF($(ele).firstChild.data, styleWidth, limition);
		}
		else if(getMyInnerText(ele).indexOf('All')<0){
			ele.innerHTML = elipseTextFF(getObjInnerText(ele), styleWidth, limition);
		}
	}
}
function setInnerText(obj, text){
	if (BrowserDetect.browser=="Explorer"){
		obj.innerText = text;
	}
	else{
		obj.text = text;
	}
}
//To get Radio Btn Value in the Form
function get_radio_value(rdlName){
	for (var i=0; i < rdlName.length; i++){
	   if (rdlName[i].checked){
	      	var rad_val = rdlName[i].value;
	      }
	   }
	   return rad_val;
}

/*
 *
 */
function downloadReports(fileTypeVal){
	var checkedCount = validateSelectType();
	if (checkedCount == 0) {
		alert(scajsMsg[1].sub("_",$('kpiTitleSpan').innerHTML));
		return false;
	}
	var poKeys=document.getElementById('hdnEntityValue').value;
	var hdnEntityColumnID=document.getElementById('hdnEntityColumnID').value;
	var hdnEntityID=document.getElementById('hdnEntityID').value;
	var hdnRowIndex=$('hdnRowIndex').value;
	$("actualDownloadLink").href = "";
	var url = "actionHandler?action=Download&poKeys="+poKeys+"&hdnEntityColumnID="+hdnEntityColumnID+"&hdnEntityID="+hdnEntityID+"&fileType="+fileTypeVal+"&hdnRowIndex="+hdnRowIndex;
	var myAjax = new Ajax.Request(url,
		{
			method: 'post',
			onSuccess:function(transport){
			$("actualDownloadLink").href = transport.responseText;
			activateActualDownloadLink();
			}
		});
}

/*
 *
 */
function activateActualDownloadLink(){
	alert("Report Generated");
	$('actualDownloadLink').click();
}

function testNand(){
	alert(1111);
}